c# - How to workaround 0x01 invalid character exception. Using Xdocument -
im trying parse folder bunch of xml files. xml files contains information vehicles. xml files autogenerated , of them has invalid characters. thing that, there many files me correct them manually. wonder how can bypass invalid character exception? invalid line in of xml files:
<ecu ecuname="abs" ecufamily="bss" cplno="" address="0x0b" configchecksum="0x00000000" updated="false">
i have tried use streamreader without success. code:
xdocument docs = xdocument.load(new system.io.streamreader((path), encoding.getencoding("utf-8"))); var namevalues = fpc in docs.descendants("fpc") select new { name = (string)fpc.attribute("name"), value = (string)fpc.attribute("value") };
if need can load file e.g.
xdocument doc; using (xmlreader xr = xmlreader.create(path, new xmlreadersettings() { checkcharacters = false })) { doc = xdocument.load(xr); } // query document here
that character references 1 have shown, not disallowed literal characters however.
Comments
Post a Comment