Re: XPath Query Exressions and Quote Characters
| From: | Jason Barnett | Date: | Wed, 16 Mar 2005 17:06:24 +0000 |
| Subject: | Re: XPath Query Exressions and Quote Characters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210904@lists.php.net to get a copy of this message | ||
C Drozdowski wrote:
...
> $query = '//book/chapter' . '[@xml:id="' . $id . '"]';
First of all check the XPath documentation:
http://www.w3.org/TR/xpath
http://www.w3.org/TR/xpath#path-abbrev
AFAIK your expression above is the way to build this query. Give us a
link to the XML doc if you want us to take a look at that specific doc.
Also make sure you referenced the correct DTD. And (just to be sure)
try to validate you document against the DTD.
>
> Given this expression, if $id contains one or more single quotes, an
> error is thrown.
>
> $query = "//book/chapter[@xml:id='$id']";
>
> I need to be able to build an exression that contains either double or
> single quotes in the search regarding of how I programatically build the
> expression.
>
A couple of things that may be in play here...
- First of all I recall there was a specific bug with xml:id, although I
can't recall off the top of my head what it was...
- Secondly the XPath querying interface in PHP will only return simple
data at this point. In fact, I think it will only return strings.
http://www.w3.org/TR/xpath#attribute-nodes
But if your ID is simple data (integer / string), I can't imagine it
would be a problem for XPath to return it.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc