I got this error while Parse an string to XDocument after edit and save it. But anyone can help me locate error position - The Line 1, position 10475. How can i get that position ???
System.Xml.XmlException: Unexpected XML declaration. The XML
declaration must be the first node in the document, and no white space
characters are allowed to appear before it. Line 1, position 10475.
if (storage.FileExists("APPSDATA.xml"))
{
var reader = new StreamReader(new IsolatedStorageFileStream("APPSDATA.xml", FileMode.Open, storage));
string xml = reader.ReadToEnd();
var xdoc = XDocument.Parse(xml);//error here
reader.Close();
The XML is big, this is jus a part of it
<?xml version="1.0" encoding="UTF-8"?>
<Ungdungs>
<Ungdung>
<Name>HERE City Lens</Name>
<Id>b0a0ac22-cf9e-45ba-8120-815450e2fd71</Id>
<Path>/Icon/herecitylens.png</Path>
<Version>1.0.0.0</Version>
<Category>HERE</Category>
<Date>Uknown</Date>
</Ungdung>
<Ungdung>
<Name>HERE Transit</Name>
<Id>adfdad16-b54a-4ec3-b11e-66bd691be4e6</Id>
<Path>/Icon/heretransit.png</Path>
<Version>1.0.0.0</Version>
<Category>HERE</Category>
<Date>Uknown</Date>
</Ungdung>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…