Page 1 of 1

XMLDOM XPath Functions

Posted: Tue Feb 06, 2007 10:07 am
by kingspice
Hi there,
I am using similar code to do an Xpath Query through XMLDOM
However, whenever I try and use the Xpath function:
lower-case
as listed as:
http://www.w3schools.com/xpath/xpath_functions.asp
I get an error about the function.

Are all the xpath functions supported by PHP 5?
e.g:

Code: Select all

$xml = '<books><book><name>Blah</name></book></books>'; 
$doc = DOMDocument::loadXML($xml); 
$xpath = new DomXpath($doc); 
$query = '/books/book[contains(lower-case(name), "blah")]';

Posted: Tue Feb 06, 2007 10:41 am
by volka
php uses libraries to support xml, xpath and xslt. You're probably using libxml2 (phpinfo() can tell you)
http://xmlsoft.org/index.html wrote:Libxml2 implements a number of existing standards related to markup languages:
[...]
XML Path Language (XPath) 1.0: http://www.w3.org/TR/xpath
http://www.w3schools.com/xpath/xpath_functions.asp refers to http://www.w3.org/2005/02/xpath-functions[quote]XQuery 1.0 and XPath 2.0 Functions and Operators[/quote]
lower-case is not listed for xpath 1.0, see http://www.w3.org/TR/xpath#section-String-Functions

Posted: Tue Feb 06, 2007 1:32 pm
by kingspice
Yeah seems like your right.
I'm using:
libxml Version 2.6.26 (latest is 2.6.27 on that site).

It appears that 2.6.27 still only provides Xpath 1.0 functionality.
Is there anyway in which I could obtain XPath 2.0 functionality through php or some other work around for this lower-case matching problem?

Thanks