c# - Data is invalid error when loading XML -
I am trying to load a very basic XML document, but every time I use the LoadXml (string URL) line The program reports crash and exceptions ("Data at the original level is invalid. Line 1, position 1" XmlException).
XmlDocument xmldoc = New XmlDocument (); Xmldoc.LoadXml (@ "C: \ Websites \ TestHarness \ TestHarness \ TestHarness \ ExampleXml.xml"); XML node = xmldoc.DocumentElement; My XML looks like this (it is a sample xml document from W3Schools and it opens in IE exactly):
& Lt; Title & gt; Reminder & lt; / Heading & gt; & Lt; Body & gt; Do not forget me at the end of this week! & Lt; / Body & gt; & Lt; / Comment & gt; This is not exactly confiscated as there is no white space.
I can not see anything wrong with this code, the stack trace does not tell me a lot and I suspect that there is an environmental issue somewhere. Anyone have any ideas?
Edit: The formatting of XML is not correct. XML is similar to the sample document here:
use load () Instead of LoadXml () .
Comments
Post a Comment