Read non standard conformant XML
-
Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below).
<RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement>
As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005 -
Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below).
<RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement>
As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005 -
One way could be to read the file into a string, replace the illegal characters with their legal code, and then read the string into an xml document. --- b { font-weight: normal; }
-
Hi! I want to read an XML file, which is not completely standard conformant. To be more precise some of its nodes contain text with special characters (see the example below).
<RootElement> <ConformantNode>Hello</ConformantNode> <NonConformantNode>You & me</NonConformantNode> </RootElement>
As you can see "NonConformantNode" contains an & char in its text, which always makes System.Xml.XmlReader throw an exception. How can I read the content of this document, in other words, how can I read an XML document without automatic character decoding? Thanks for your help in advance! P.S.: I already tried setting XmlReaderSettings.CheckCharacters to false, but this doesn't do the trick. -- modified at 8:01 Saturday 17th September, 2005