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 YeowCheong Pua <pu...@email.com> on 2001/04/03 07:54:15 UTC

How to set '&' as an attribute value using setAttribute()?

How do I set '&' as a attribute value using the setAttribute() method of the Element class? The method seems to blindly convert all '&' chars in the string to "&". eg

setAttribute("test","a&b")
gives output as 
test="a&amp;b"

setAttribute("test","a&amp;b")
gives
test="a&amp;amp;b"

setAttribute("test","a&#38;#38;b");
gives
test="a&amp;#38;#38;b"

How to get 
test="a&b"?

-----------------------------------------------
FREE! The World's Best Email Address @email.com
Reserve your name now at http://www.email.com



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


RE: How to set '&' as an attribute value using setAttribute()?

Posted by "Julian F. Reschke" <ju...@gmx.de>.
This is the correct serialization of "&". Don't worry. Any conforming XML
parser will deliver it back as "&" to your application.

> -----Original Message-----
> From: YeowCheong Pua [mailto:puayc@email.com]
> Sent: Tuesday, April 03, 2001 7:54 AM
> To: xerces-j-user@xml.apache.org
> Subject: How to set '&' as an attribute value using setAttribute()?
>
>
> How do I set '&' as a attribute value using the setAttribute()
> method of the Element class? The method seems to blindly convert
> all '&' chars in the string to "&". eg
>
> setAttribute("test","a&b")
> gives output as
> test="a&amp;b"
>
> setAttribute("test","a&amp;b")
> gives
> test="a&amp;amp;b"
>
> setAttribute("test","a&#38;#38;b");
> gives
> test="a&amp;#38;#38;b"
>
> How to get
> test="a&b"?
>
> -----------------------------------------------
> FREE! The World's Best Email Address @email.com
> Reserve your name now at http://www.email.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