Problem in Loading xml with encoding UTF 16 using XDocument
Solution:
Or
That solved my problem.
I was getting error " There is no Unicode byte order mark. Cannot switch to Unicode, when i was trying to read the xml document using XDocument method .
Xml had encoding
Xml had encoding
<?xml version="1.0" encoding="utf-16"?>
When i removed encoding manually.It works perfectly.
I had tried
I had tried
XDocument xdoc = XDocument.Load(path);
So what was the problem ?
Solution:
XDocument xdoc = XDocument.Parse(System.IO.File.ReadAllLines(path));
Or
using (StreamReader sr = new StreamReader(path, true))
{
XDocument xdoc = XDocument.Load(sr);
}
That solved my problem.
0 comments:
Post a Comment