I am trying to create a simple application that reads XML using SAX (XmlTextReader) from a stream that contains not only XML, but also other data such as binary drops and text. The flow structure is simply based on a piece.
When I enter my read function, the stream is correctly placed at the beginning of the XML. I reduced the problem to the following code example:
string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><Models />" + (char)0x014;
XmlTextReader reader = new XmlTextReader(new StringReader(xml));
reader.MoveToContent();
reader.ReadStartElement("Models");
These few lines throw an exception when calling ReadStartElement due to 0x014 at the end of the line.
The interesting thing is that the code works just fine when using the following input:
string xml = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><Models></Models>" + (char)0x014;
I don’t want to read the whole document because of its size and I don’t want to change the input data, because I need to stay backward compatible with older data entries.
, , - , , .
? LINQ XDocument, .
,
Cheers,
Romout