[Expat-discuss] Problem parsing a string with special character '&'

Nick MacDonald nickmacd at gmail.com
Mon Dec 5 16:59:34 CET 2005


Reading the XML 1.1 standard document (from
http://www.w3.org/TR/2004/REC-xml11-20040204/ ) in section 2.4 you find the
following text:

The ampersand character (&) and the left angle bracket (<) MUST NOT appear
in their literal form, except when used as markup delimiters, or within a
comment, a processing instruction, or a CDATA section. If they are needed
elsewhere, they MUST be escaped using either numeric character references or
the strings "&amp;" and "&lt;" respectively. The right angle bracket (>) MAY
be represented using the string "&gt;", and MUST, for compatibility, be
escaped using either "&gt;" or a character reference when it appears in the
string "]]>" in content, when that string is not marking the end of a CDATA
section.

So, when you used &amp; did you include the semicolon?
For example:
<audio uri="
annlab://VarAnn/format?type5=digits&amp;value5=0122333&amp;locale5=en_US">

(Note, I personally have not tested this recommendation in Expat, but it
makes sense from my reading of the XML spec.)

Nick


On 12/5/05, shakeel.ahmed at wipro.com <shakeel.ahmed at wipro.com> wrote:
>
>
> I'm having problems parsing an XML document with a tag <audio
> uri="annlab://VarAnn/format?type5=digits&value5=0122333&locale5=en_US">.
> I get a XML parsing error everytime I use the special character & in the
> string. Tried using &amp instead, but it does not help.
>
> Expat is able to parse other characters like '!' etc.
>
> Would greatly appreciate any suggestions/solutions for this problem.
>

--
Nick MacDonald
NickMacD at gmail.com


More information about the Expat-discuss mailing list