Loading xml with encoding UTF 16 using XDocument

Posted by Sangram on Stack Overflow See other posts from Stack Overflow or by Sangram
Published on 2010-12-31T07:36:18Z Indexed on 2010/12/31 7:54 UTC
Read the original article Hit count: 211

Filed under:
|
|
|
|

Hi,

I am trying to read the xml document using XDocument method . but i am getting an error when xml has

<?xml version="1.0" encoding="utf-16"?>

When i removed encoding manually.It works perfectly.

I am getting error " There is no Unicode byte order mark. Cannot switch to Unicode. "

i tried searching and i landed up here-->

Why does C# XmlDocument.LoadXml(string) fail when an XML header is included?

But could not solve my problem.

My code :

XDocument xdoc = XDocument.Load(path);

Any suggestions ??

thank you.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml