Closed GoogleCodeExporter closed 9 years ago
This may be caused by the fact that for XML, special characters such as '&'
should be encoded or escaped.
Read the following post
---------------------------------------------------------------
Characters like "<" and "&" are illegal in XML elements.
"<" will generate an error because the parser interprets it as the start of a
new
element.
"&" will generate an error because the parser interprets it as the start of an
character entity.
Some text, like JavaScript code, contains a lot of "<" or "&" characters. To
avoid
errors script code can be defined as CDATA.
Everything inside a CDATA section is ignored by the parser.
A CDATA section starts with "<![CDATA[" and ends with "]]>"
Original comment by John.Jian.Fang@gmail.com
on 13 Feb 2009 at 3:03
An ampersand (&) may be escaped numerically (&) or with a general
entity
(&).
<SUPPLIERCOMPANYNAME>JONSON & JONSON</SUPPLIERCOMPANYNAME>
Original comment by John.Jian.Fang@gmail.com
on 13 Feb 2009 at 3:11
ublic string XMLEncode(string Value)
{
return Value.Replace ("&", "&").Replace("'", "'").Replace ("\"",
""").Replace ("<", "<").Replace(">", ">");
}
public string XMLDecode(string Value)
{
return Value.Replace ("&", "&").Replace("'", "'").Replace ("<",
"<").Replace (">", ">");
}
Original comment by John.Jian.Fang@gmail.com
on 13 Feb 2009 at 3:16
Seems fixed the problem if we using replacement for the special characters, but
need
to remember to replace it back with do saving.
Original comment by John.Jian.Fang@gmail.com
on 13 Feb 2009 at 9:19
Original issue reported on code.google.com by
John.Jian.Fang@gmail.com
on 13 Feb 2009 at 3:40