Re: Expat not parsing this Tag

[email protected]
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
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="[email protected]"]"></
> 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[@[email protected]]"></
> 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='[email protected]']"></
delete-evt>

or escape your double quotes as usual

<delete-evt
nselecing="a-list[@name=&quot;friends&quot;]/point[@myip=&quot;[email protected]&quot;]"></
delete-evt>

rolf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.