2

at the moment im loading xml and i am getting error:

System.Xml.XmlException: ' ', hexadecimal value 0x17, is an invalid character. Line 2762, position 16.

it is easy to fix. just open xml and remove the character.

but I need to know is it possible to load xml even with invalid characters and use it for parsing. and is there any downside?

xml example:

<?xml version="1.0" encoding="UTF-8"?>
<all>
<sub>
    <summary>this is summary and it might have some invalid chars</summary>
</sub>
<sub>
    <summary>this one is ok</summary>
</sub>
</all>
1
  • can you show us the XML in question?? Commented Mar 12, 2010 at 6:19

2 Answers 2

4

Xml with invalid characters in it is not xml. It could be an isolated glitch, or it could be a portent that there is significant data corruption throughout the file - some which manifests as invalid characters (breaking standard readers), and some which silently damages your data without you noticing.

I would treat the entire thing as suspect (i.e. reject it) and get it fixed at source.

Sign up to request clarification or add additional context in comments.

Comments

0

not sure exactly how it works in c# but if you could some how get it to parse an xml from a 'string' not a file, you could first load the file into a 'string' filter the string yourself, then send it off for xml parsing.

Edit:

maybe 'string' is a poor choice, as the corrupt data might have NULLs in it ect, A byte array or some other generic memory stream structure?

1 Comment

yes it is possible and im using it for now thx. LoadXml(string xml);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.