You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Andreas Schlegel <sc...@software.b.uunet.de> on 2002/03/13 13:35:29 UTC

Is it a problem to parse values containing '&' -?

Hi,

reading a XML string with SAXParser.class to generate an DOM (JDOM) I
get the following SAXParseException:
org.xml.sax.SAXParseException: The reference to entity "W" must end with

the ';' delimiter.

This happens if I parse a string containing values like this one:
<comp>B&W</comp>

But what can I do handle the problem?

Greetings,
Andreas


Environment:
xerces-j: build 11/15/2001
jdk 1.3.1.1




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Is it a problem to parse values containing '&' -?

Posted by Andy Clark <an...@apache.org>.
Andreas Schlegel wrote:
> ok, I have to replace the HTML tags <, >, &, " - or are there much more
> characters to replace?

Attribute values quoted using a single quote (') must escape
occurrences of single quotes with &apos;. And attribute values
that quoted using a double quote (") must escape occurrences
of double quotes with &quot;. For example:

  <root single='Don&apos;t' double="say &quot;Hi&quot;"/>

But single and double quotes don't have to be escaped in 
character content. So the following is OK:

  <root>Don't say "Hi"</root>

In short:

  Attributes - <, &, and (' or ", depending on what quote was used)
  Content    - < and &

-- 
Andy Clark * andyc@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Is it a problem to parse values containing '&' -?

Posted by Andreas Schlegel <sc...@software.b.uunet.de>.
Yonghui Chen wrote:

> replace & with &amp;

ok, I have to replace the HTML tags <, >, &, " - or are there much more
characters to replace?

Greetings,
Andreas


>
> ----- Original Message -----
> From: "Andreas Schlegel" <sc...@software.b.uunet.de>
> To: <xe...@xml.apache.org>
> Sent: Wednesday, March 13, 2002 8:35 PM
> Subject: Is it a problem to parse values containing '&' -?
>
> > Hi,
> >
> > reading a XML string with SAXParser.class to generate an DOM (JDOM) I
> > get the following SAXParseException:
> > org.xml.sax.SAXParseException: The reference to entity "W" must end with
> >
> > the ';' delimiter.
> >
> > This happens if I parse a string containing values like this one:
> > <comp>B&W</comp>
> >
> > But what can I do handle the problem?
> >
> > Greetings,
> > Andreas
> >
> >
> > Environment:
> > xerces-j: build 11/15/2001
> > jdk 1.3.1.1
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Is it a problem to parse values containing '&' -?

Posted by Yonghui Chen <ch...@yahoo.com>.
replace & with &amp;
----- Original Message ----- 
From: "Andreas Schlegel" <sc...@software.b.uunet.de>
To: <xe...@xml.apache.org>
Sent: Wednesday, March 13, 2002 8:35 PM
Subject: Is it a problem to parse values containing '&' -?


> Hi,
> 
> reading a XML string with SAXParser.class to generate an DOM (JDOM) I
> get the following SAXParseException:
> org.xml.sax.SAXParseException: The reference to entity "W" must end with
> 
> the ';' delimiter.
> 
> This happens if I parse a string containing values like this one:
> <comp>B&W</comp>
> 
> But what can I do handle the problem?
> 
> Greetings,
> Andreas
> 
> 
> Environment:
> xerces-j: build 11/15/2001
> jdk 1.3.1.1
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org