XMLDOM XPath Functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingspice
Forum Newbie
Posts: 2
Joined: Tue Feb 06, 2007 9:59 am

XMLDOM XPath Functions

Post 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")]';
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
kingspice
Forum Newbie
Posts: 2
Joined: Tue Feb 06, 2007 9:59 am

Post 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
Post Reply