I've tried to use the XPath 2.0 exp //span/string(.) in libxml2, but it doesn't work.
So, my question is: does libxml2 support XPath 2.0 or not?
- 24,148
 - 7
 - 127
 - 265
 
- 375
 - 6
 - 24
 
4 Answers
According to this 2007 email from the maintainer of libxml2, libxml2 does not, and will not, support XPath 2.0.
- 191
 - 1
 - 3
 
As far as I know -- not. The prevailing majority of XPath 2.0 implementations are part of XSLT 2.0 processors or XQuery processors.
- 240,661
 - 26
 - 293
 - 431
 
Libxml2 implements a number of existing standards related to markup languages:
the XML standard: http://www.w3.org/TR/REC-xml Namespaces in XML: http://www.w3.org/TR/REC-xml-names/ XML Base: http://www.w3.org/TR/xmlbase/ RFC 2396 : Uniform Resource Identifiers http://www.ietf.org/rfc/rfc2396.txt XML Path Language (XPath) 1.0: http://www.w3.org/TR/xpath HTML4 parser: http://www.w3.org/TR/html401/ XML Pointer Language (XPointer) Version 1.0: http://www.w3.org/TR/xptr XML Inclusions (XInclude) Version 1.0: http://www.w3.org/TR/xinclude/ ISO-8859-x encodings, as well as rfc2044 [UTF-8] and rfc2781 [UTF-16] Unicode encodings, and more if using iconv support part of SGML Open Technical Resolution TR9401:1997 XML Catalogs Working Draft 06 August 2001: http://www.oasis-open.org/committees/entity/spec-2001-08-06.html Canonical XML Version 1.0: http://www.w3.org/TR/xml-c14n and the Exclusive XML Canonicalization CR draft http://www.w3.org/TR/xml-exc-c14n Relax NG, ISO/IEC 19757-2:2003, http://www.oasis-open.org/committees/relax-ng/spec-20011203.html W3C XML Schemas Part 2: Datatypes REC 02 May 2001 W3C xml:id Working Draft 7 April 2004
Since libxml2 supports XPath 1.0, the syntax is incorrect:
//span/string(.)
Should be:
string(//span/.)
For clarification, the string method is part of XPath 1.0 as well. For future reference:
libxml2 supports XPath 1.0
Objective-C supports XPath 2.0 via the
nodesForXPathmethod of NSXMLNode in GNUStep/NextStep
The Cocoa implementation uses XPath 2.0, which is a World Wide Web Consortium recommendation.
References
- 24,148
 - 7
 - 127
 - 265
 
- 
                    I don't think this is right; at least, [this answer](http://stackoverflow.com/a/2821094/179332) indicates that `//span/string(.)` is valid XPath 2.0. – Adam Spiers Sep 23 '15 at 17:57
 - 
                    @AdamSpiers I answered this question: `So, my question is: does libxml2 support XPath 2.0 or not?` – Paul Sweatte Sep 23 '15 at 19:27
 
you might be interested in an XPath 2.0 extension to libxml2 - however, 2 caveats apply: it's work in progress and it's free for non-commercial use only.
hope this helps,
best regards, carsten
ps: i am neither affiliated with the guys working on libx nor have i any personal experience on using it or knowledge beyond the info from their website.
- 17,010
 - 4
 - 35
 - 61