Showing posts with label There is an error in XML document (2. Show all posts
Showing posts with label There is an error in XML document (2. Show all posts

Tuesday, 14 April 2015

There is an error in XML document (2,



I was trying to read XML file.
I have converted XML in to string, then i have Deserialize the string.
I was getting above error.

Solution:
While reading XML in to string, some of the XML values are decoding.
So those values are giving the error,i replaced actual values...

    XmlTextReader strreader = new XmlTextReader("c:\myxml.xml");
string temp = strreader.Value;

temp = temp.Replace("'", "&apos;").Replace("&", "&amp;").Replace("\"", "&quot;").Replace(">", "&gt;").Replace("<", "&lt;");

Ref more: http://microsoft-techies.blogspot.com/2015/04/read-special-characters-back-from.html