The XML structure parses some special characters, especially & <
so we need to put the structure in CDATA in the process,CDATA The contents of the XmlDocument will be automatically ignored when parsing, will not parse the contents; Therefore, I need CDATA here to save the HTML character content, as follows:
<xml><datatype><![ cdata[2]]></datatype></xml>
C # Daemon parsing does not change:
StreamReader stream = new StreamReader (context. Request.inputstream); The value of post via Ajax, which is the XML character above
string xml = Stream. ReadToEnd (); The data inside the post
XmlDocument doc = new XmlDocument ();
Try
{
Doc. LOADXML (XML);
}
catch (XmlException ex)
{
Context. Response.Write (ex. Message);
Return
}
XmlElement root = Doc. DocumentElement;
string datatype = root. selectSingleNode ("datatype"). InnerText;
Error parsing in ASP. XmlDocument, handling special characters