I have to process a wannabe XML string.
It hasn't got a root element (for reasons unknown), but I can't do much about it.
So I decided to stick a dummy root node around the entire XML and then feed it into the
XMLDocument
.
The XML in question looks like:
<mynode>
blah
<morenodes>
blah
blah
</morenodes>
</mynode>
blah
<morenodes>
blah
blah
</morenodes>
...
So to cheat, I decided to do
<root>
<mynode>
blah
<morenodes>
blah
blah
</morenodes>
</mynode>
<mynode>
blah
<morenodes>
blah
blah
</morenodes>
</mynode>
...
</root>
Thinking this is fairly straight forward, I did
string newString = "<root>" + oldString + "</root>";
XMLDocument xmlDolcument = new XMLDocument();
xmlDocument.Load(newString);
where
oldString
is where the original XML is found.
For some reason, the <Root> tag gets added OK, but the </Root> refuses to be added whatever I try.
What's so hard about string concatenation, and what am I doing that's so horribly wrong?
Please help!
[Edit] Formatting went wrong and the ending tag disappeared...