The string contains special characters like &, ' , etc.. When I use XmlDoc.LoadXml(string), it is throwing exception like '' is an unexpected token. Expecting a white space..
Could some one please help me in reading this string in a proper way? I dont want to replace the characters.. I would like to use something like XmlReader or similar mechanism to read it into the XmlDocument..
The string contains special characters like &, ' , etc.. When I use XmlDoc.LoadXml(string), it is throwing exception like '' is an unexpected token. Expecting a white space..
Yes,as far as I see,you cannot use specific characters in the xml,or it will be reguarded as part of xml elements,which will cause this problem。
So you have to use something like string.Replace to replace all the specific characters to something like encoded ones——
madugulad
Member
164 Points
31 Posts
Reading a string into XmlDocument
Jun 05, 2012 09:53 PM|LINK
Hi I'm reading a string into an xml document.
The string contains special characters like &, ' , etc.. When I use XmlDoc.LoadXml(string), it is throwing exception like '' is an unexpected token. Expecting a white space..
Could some one please help me in reading this string in a proper way? I dont want to replace the characters.. I would like to use something like XmlReader or similar mechanism to read it into the XmlDocument..
Thanks.
amosCabanban...
Member
441 Points
142 Posts
Re: Reading a string into XmlDocument
Jun 05, 2012 11:57 PM|LINK
special characters have encoding codes for xml... http://weblogs.sqlteam.com/mladenp/archive/2008/10/21/Different-ways-how-to-escape-an-XML-string-in-C.aspx
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Reading a string into XmlDocument
Jun 07, 2012 02:25 AM|LINK
Yes,as far as I see,you cannot use specific characters in the xml,or it will be reguarded as part of xml elements,which will cause this problem。
So you have to use something like string.Replace to replace all the specific characters to something like encoded ones——
【e.g]】
> changes to >
< changes to <