D
darrel
In our CMS, every time a page is updated, we spit out a new XML file.
This file is written via a function that queries the Database using a
recursive function, grabs the data, and writes out a file using
xmltextwriter:
Dim fs As New
System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("/mjb05/xml/"
& siteID & "/siteMenu.xml").ToString, IO.FileMode.Open, IO.FileAccess.Write,
IO.FileShare.Read)
objXMLWriter = New System.xml.XmlTextWriter(fs, Nothing)
'objXMLWriter = New
System.xml.XmlTextWriter(System.Web.HttpContext.Current.Server.MapPath("/mjb05/xml/"
& siteID & "/siteMenu.xml").ToString, Nothing)
objXMLWriter.Flush()
objXMLWriter.Formatting = objXMLWriter.Formatting.Indented
objXMLWriter.Indentation = 3
objXMLWriter.WriteStartDocument()
objXMLWriter.WriteComment("Created on " & Now())
objXMLWriter.WriteStartElement("menuItems")
createParentNode = False
....etc.
This works 99% of the time. However, if I change a particular value in one
of my table cells the writer still executes, but then writes out an invalid
ending to the file.
What is REALLY odd is that I can re-write the file a second time and it
fixes itself.
What is even odder (yes, it gets odder) is the way the file is corrupted.
It's appending a weird bit of broken nodes to the end of the file.
For instance, if my file SHOULD end like this:
</endNode>
</endAllItems>
the corrupted file might look like this:
</endNode>
</endAllItems>
</endNode>
</endAllItems>
or this:
</endNode>
</endAllItems>endNode>
</endAllItems>
or even just this:
</endNode>
</endAllItems>s>
Anyone have any ideas what could cause this type of weird corruption when
writing out an XML file?
-Darrel
This file is written via a function that queries the Database using a
recursive function, grabs the data, and writes out a file using
xmltextwriter:
Dim fs As New
System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("/mjb05/xml/"
& siteID & "/siteMenu.xml").ToString, IO.FileMode.Open, IO.FileAccess.Write,
IO.FileShare.Read)
objXMLWriter = New System.xml.XmlTextWriter(fs, Nothing)
'objXMLWriter = New
System.xml.XmlTextWriter(System.Web.HttpContext.Current.Server.MapPath("/mjb05/xml/"
& siteID & "/siteMenu.xml").ToString, Nothing)
objXMLWriter.Flush()
objXMLWriter.Formatting = objXMLWriter.Formatting.Indented
objXMLWriter.Indentation = 3
objXMLWriter.WriteStartDocument()
objXMLWriter.WriteComment("Created on " & Now())
objXMLWriter.WriteStartElement("menuItems")
createParentNode = False
....etc.
This works 99% of the time. However, if I change a particular value in one
of my table cells the writer still executes, but then writes out an invalid
ending to the file.
What is REALLY odd is that I can re-write the file a second time and it
fixes itself.
What is even odder (yes, it gets odder) is the way the file is corrupted.
It's appending a weird bit of broken nodes to the end of the file.
For instance, if my file SHOULD end like this:
</endNode>
</endAllItems>
the corrupted file might look like this:
</endNode>
</endAllItems>
</endNode>
</endAllItems>
or this:
</endNode>
</endAllItems>endNode>
</endAllItems>
or even just this:
</endNode>
</endAllItems>s>
Anyone have any ideas what could cause this type of weird corruption when
writing out an XML file?
-Darrel