开发者

problem while encoding string to XML

i am gettting problem while encoding string R.F.< 1 into X开发者_JAVA技巧ml

i am using node.innerxml=string;

it shows exeption name cannot start with 1 or hexadecimal value 0x33.....

pls help me to solve this


The InnerXml property of an XmlNode instance accepts only well-formed XML text. Whenever you attempt to apply the string R.F.< 1, the less-than character is being interpreted as the beginning of an XML element tag. Since an element name cannot begin with a digit, the XML is deemed not to be well-formed, and the set operation fails.

If you wish to put arbitrary text inside an XmlNode, then you should use the InnerText property rather than the InnerXml property. This will ensure that the less-than character is properly escaped (R.F.&lt; 1) in the resulting XML document.


When encoding to XML you need to consider reserved XML characters, and encode them accordingly.

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜