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:
signature.asc
Description: OpenPGP digital signature