XML Error

B

Bill English

I want to convert a string to an XML document, but it always throws an
exception at the last character of the document. It says the
hexadecimal value 0x00 is not a valid character. What can I do?

Note to convert the string, I use:

XmlDocument doc = new XmlDocument();
doc.LoadXml(myxmlstring); <----- EXCEPTION AT THIS LINE OF CODE
 
C

Chris R. Timmons

I want to convert a string to an XML document, but it always
throws an exception at the last character of the document. It
says the hexadecimal value 0x00 is not a valid character. What
can I do?

Note to convert the string, I use:

XmlDocument doc = new XmlDocument();
doc.LoadXml(myxmlstring); <----- EXCEPTION AT THIS LINE OF CODE

Bill,

Trim the null character(s) from the end of the string:

doc.LoadXml(myxmlstring.TrimEnd(new char[] { '\0' }));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top