XPath Query Exressions and Quote Characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've got a problem with quote characters and building XPath query expressions (PHP 5.0.3). What do I need to do to get them to work? I've tried various encoding functions but cannot figure it out.

Given this expression, if $id contains one or more double quotes, an error is thrown.

$query = '//book/chapter' . '[@xml:id="' . $id . '"]';

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.

Any insight would be appreciated.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux