Im trying to parse a folder with a bunch of xml files. The xml files contains information about some vehicles. The XML files are autogenerated and i some of them has invalid characters. The thing is that, there are too many files for me to correct them manually. So i wonder how i can bypass the invalid character exception? This is the invalid line in some of the xml files:
<ECU EcuName="ABS" EcuFamily="BSS" CplNo="" Address="0x0B" ConfigChecksum="0x00000000" Updated="false">
I have tried to use Streamreader without any success. This is my code:
XDocument docs = XDocument.Load(new System.IO.StreamReader((path), Encoding.GetEncoding("utf-8")));
var nameValues =
from fpc in docs.Descendants("FPC")
select new
{
Name = (string)fpc.Attribute("Name"),
Value = (string)fpc.Attribute("Value")
};