Re: How to parse XML which contains & in the text ?
- From: "Daniel Dyer" <"You don't need it">
- Date: Wed, 14 Feb 2007 11:39:51 -0000
On Wed, 14 Feb 2007 11:31:18 -0000, sohan.soni@xxxxxxxxx <sohan.soni@xxxxxxxxx> wrote:
When Parsing (i.e. converting this XML doc to String) this XML file
using Java code, I am getting following exception.
org.xml.sax.SAXParseException: Next character must be ";" terminating
reference to entity "Value".
Section 2.4 of the XML 1.0 specification:
"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 "&" and "<" respectively. The right angle bracket (>) may be represented using the string ">", and MUST, for compatibility, be escaped using either ">" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section."
I think there is some changes/modification needed in DTD to treat the
string in XML which contains & as a literal, instead of expecting some
entity.
You can't fix this in the DTD, the XML is invalid and the parser is correct to reject it.
Adding to this, XML content is not under our control.
Unforunately, the only rational fix *is* to change the XML. Either use & or wrap the element data in a CDATA section. If the XML is controlled by a third part it would be reasonable to request that they change it since it is not really XML at all if it is not valid.
Dan.
--
Daniel Dyer
http://www.uncommons.org
.
- Follow-Ups:
- Re: How to parse XML which contains & in the text ?
- From: sohan.soni@xxxxxxxxx
- Re: How to parse XML which contains & in the text ?
- References:
- How to parse XML which contains & in the text ?
- From: sohan.soni@xxxxxxxxx
- How to parse XML which contains & in the text ?
- Prev by Date: How to parse XML which contains & in the text ?
- Next by Date: JADE with PHP/html
- Previous by thread: How to parse XML which contains & in the text ?
- Next by thread: Re: How to parse XML which contains & in the text ?
- Index(es):
Relevant Pages
|