[Expat-discuss] Expat not parsing this Tag
rolf@pointsman.de
rolf at pointsman.de
Thu Oct 6 13:26:14 CEST 2005
On 6 Oct, Ajit Kumar wrote:
> I am facing a problem while parsing one xml document, which has a tag
> like this-
> <delete-evt
> nselecing="a-list[@name="friends"]/point[@myip="ajit at yahoo.com"]"></
> delete-evt>
> Expat is exiting as soon as it visits this tag. Giving the error code to
> be "not well-formed".
Expat is right. See production 10 of the XML recommendation. If you
use '"', to delimit attribute values, you can't use a literal '"' within the
attribute value, as you did.
> If I change the same tag as this (after removing the internal quotes)-
> <delete-evt
> nselecing="a-list[@name=friends]/point[@myip=ajit at yahoo.com]"></
> delete-evt>
> the expat has no problem in parsing the above changed Tag.
>
> I will be thankful for any solution that will allow me to parse the Tag
> in its first original form.
The original form isn't well-formed XML, every compliant XML parser
*must* report error.
You've mainly two options. Since your attribute value looks like an
XPath expr, just use single quotes inside the XPath expr (that is fine
with every XPath engine)
<delete-evt
nselecing="a-list[@name='friends']/point[@myip='ajit at yahoo.com']"></
delete-evt>
or escape your double quotes as usual
<delete-evt
nselecing="a-list[@name="friends"]/point[@myip="ajit at yahoo.com"]"></
delete-evt>
rolf
More information about the Expat-discuss
mailing list