Throws an exception when reading the xml file in the line:

XDocument xDoc = XDocument.Load(pathXmlFile); 

In the first case, it gives an error, but in the second there is no, I don’t see any difference in the names of the path, everything is identical.

enter image description here

enter image description here

 <?xml version="1.0" encoding="UTF-8"?> <report> <eeprom version="ENHANCED PBB/ЂB cor/dens v10.12" datetime=""></eeprom> <sn>015.15.01.002</sn> <file path="\internal\analog.tar" type="tar"> <point> <x>-11,0000000</x> <y>1,6000000</y> </point> <point> <x>-0,0500000</x> <y>0,0000000</y> </point> </file> <file path="\external\density.cor" type="cor"> <surface> <a0>94,5305710</a0> <a1>-0,0142365</a1> <a2>-0,0043975</a2> <a11>-0,0000980</a11> <a22>0,0001461</a22> <a12>-0,0000220</a12> <p>1,0000000</p> </surface> <surface> <a0>-266,8311768</a0> <a1>-3,8060381</a1> <a2>1,8994861</a2> <a11>0,0000000</a11> <a22>0,0000000</a22> <a12>0,0000000</a12> <p>3,0000000</p> </surface> <surface> <a0>0,0000000</a0> <a1>0,0000000</a1> <a2>0,0000000</a2> <a11>-0,0004314</a11> <a22>0,0000001</a22> <a12>0,0000000</a12> <p>6,0000000</p> </surface> <surface> <a0>-13,4954958</a0> <a1>0,0428321</a1> <a2>-0,0312684</a2> <a11>0,0000000</a11> <a22>0,0000000</a22> <a12>0,0000000</a12> <p>7,0000000</p> </surface> <surface> <a0>1000,0000000</a0> <a1>0,0000000</a1> <a2>100,0000000</a2> <a11>0,1000000</a11> <a22>10,0000000</a22> <a12>0,1000000</a12> <p>5,0000000</p> </surface> </file> <file path="\internal\pressure.tar" type="tar"> <point> <x>2360,0000000</x> <y>0,0000000</y> </point> <point> <x>3532,0000000</x> <y>58,4000015</y> </point> <point> <x>4547,0000000</x> <y>103,8000031</y> </point> <point> <x>5764,0000000</x> <y>158,6999969</y> </point> <point> <x>6877,0000000</x> <y>209,0000000</y> </point> <point> <x>7900,0000000</x> <y>255,1999969</y> </point> <point> <x>8982,0000000</x> <y>304,0000000</y> </point> <point> <x>10074,0000000</x> <y>352,7999878</y> </point> <point> <x>11149,0000000</x> <y>400,8999939</y> </point> </file> <file path="\external\density.tar" type="tar"> <point> <x>0,8943808</x> <y>0,0000000</y> </point> <point> <x>1,0004297</x> <y>1,0000000</y> </point> <point> <x>1,0124259</x> <y>1,1160001</y> </point> <point> <x>1,0233793</x> <y>1,2240000</y> </point> <point> <x>1,0292079</x> <y>1,2840000</y> </point> <point> <x>1,0409085</x> <y>1,4030000</y> </point> <point> <x>1,0498325</x> <y>1,4930000</y> </point> <point> <x>1,0583036</x> <y>1,5800000</y> </point> <point> <x>1,0686287</x> <y>1,6900001</y> </point> <point> <x>1,0780404</x> <y>1,7860010</y> </point> <point> <x>1,0865008</x> <y>1,8940001</y> </point> <point> <x>1,0918074</x> <y>1,9540000</y> </point> </file> <file path="\external\coriol.tar" type="tar"> <point> <x>0,0000000</x> <y>0,0000000</y> </point> <point> <x>1,0423599</x> <y>8,8731651</y> </point> </file> <file path="\external\rotate.tar" type="tar"> <point> <x>0,2771824</x> <y>0,0000000</y> </point> <point> <x>51,5987129</x> <y>-0,8832195</y> </point> <point> <x>102,9263687</x> <y>-2,8315117</y> </point> <point> <x>161,3097382</x> <y>-4,0044746</y> </point> <point> <x>203,9690857</x> <y>-3,2529044</y> </point> <point> <x>250,3599396</x> <y>-4,8435221</y> </point> <point> <x>302,4907227</x> <y>-6,9018602</y> </point> <point> <x>351,8223267</x> <y>-5,4620886</y> </point> <point> <x>396,1837158</x> <y>-6,5484858</y> </point> </file> <file path="\internal\rgr.tar" type="tar"> <point> <x>1,0000000</x> <y>0,0000000</y> </point> <point> <x>1,1160051</x> <y>-7,7440825</y> </point> <point> <x>1,2240053</x> <y>-4,7421026</y> </point> <point> <x>1,2839999</x> <y>-1,4837382</y> </point> <point> <x>1,4029999</x> <y>0,6799557</y> </point> <point> <x>1,4930004</x> <y>3,0734160</y> </point> <point> <x>1,5800005</x> <y>4,8079190</y> </point> <point> <x>1,6899979</x> <y>6,9035168</y> </point> <point> <x>1,7860079</x> <y>7,7395725</y> </point> <point> <x>1,8939825</x> <y>9,9293804</y> </point> <point> <x>1,9540000</x> <y>8,4871855</y> </point> </file> <file path="\internal\CorKRoP.tar" type="tar"> <point> <x>0,0000000</x> <y>1,0000000</y> </point> <point> <x>1,0000000</x> <y>1,0000000</y> </point> </file> </report> 

Closed due to the fact that off-topic participants Grundy , aleksandr barakin , Pavel Mayorov , fori1ton , D-side 7 May '16 at 21:23 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Grundy, aleksandr barakin, Pavel Mayorov, fori1ton, D-side
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Error: Invalid character for specified encoding, line 3, position 32 - SVD102
  • one
    What is the content of the XML file? What do the two screen shots mean? What is the actual encoding of the XML file? - ߊߚߤߘ
  • Encoding - utf - 8 (w \ o), 2 pictures indicate the path to the file (type string) - SVD102
  • one
    There is some kind of icon on this place where line 3, position 32 is nzeemin
  • one
    99% sure that the file is not stored in utf-8. I'm already tired of fighting with those who edit xml in simple text editors like Notepad (by default it saves files in ANSI). - Alexander Petrov

1 answer 1

  Решил проблему так: StreamReader reader = File.OpenText(pathXmlFile); string streamContents; streamContents = reader.ReadToEnd(); var xDoc= XDocument.Parse(streamContents);