I am trying to extract specific fields out of XML documents using
XPathDocument & Xpath. The basic code outline is as follows:
try {
...//Load file as XpathDocument ..
XPathDocument xp = new XPathDocument(filename, System.Xml.XmlSpace.None);
//Select the required nodes..
....
}
catch(Exception e)
{
errlog.WriteLine("\nERROR :{0}", e.Message);
errlog.WriteLine("ERROR TARGETSITE: {0}", e.TargetSite);
errlog.WriteLine("ERROR SOURCE: {0}", e.Source);
}
While processing some of those files, I get an error. The error (from the
catch statement) is as follows:
ERROR: '', hexadecimal value 0x1A, is an invalid character. Line 1, position
31425.
ERROR TARGETSITE: Int32 ScanContent()
ERROR SOURCE: System.Xml
The input XML files are generated by software from a third-party vendor. Is
there a way to ignore the 0x1A character? How can I continue processing such
files? Is there some property of XPathDocument that allows you to bypass
these characters? I looked in MSDN/Google, but couldn't find anything.
All suggestions/help appreciated.
thanks!