modifying pseudo-xml doc before it hits XmlDocument.Load

unikumanihg

New Member
I have a series of... pseudo-xml files. What I mean by this, is they are almost XML files, but they are missing the xml declaration and a root node. e.g. conceptually it may look like this:\[code\]<a>info</a><b>info2</b>\[/code\]What I want to do is load it into an \[code\]XmlDocument\[/code\] object, e.g something similar to this:\[code\] XmlDocument xml = new XmlDocument(); using (StreamReader file = new StreamReader(File.Open(@"file.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { xml.Load(file); }\[/code\]This is throwing errors, most likely due to the ill formatted pseudo-xml file. I need to somehow handle adding in a root node before it hits the \[code\]Load\[/code\]. I don't want to modify the actual file, or have to save anything to disk (e.g. a new temp file). I'm stuck on this, any suggestions?
 
Back
Top