views:

395

answers:

4

Do any VBA libraries exist which will allow me to use XPath 2.0 within VBA? MSXML6 does not work with XPath 2.0.

Basically, I want to parse XML documents using XPath 2.0 as it allows me to use functions within the XPath expression to filter the XML document. As an example, the usage of the function current-date() would be useful as I would be able to retrieve data greater than a certain date. If I used XPath 1.0, I would need to arbitrary loop though the dates returned by the XPath and compare which dates were greater than a certain date.

Do you have any ideas as to how I could use XPath 2.0 within Excel 2003 VBA or any alternatives to my problem?

Thanks in advance for any help.

Donald

+1  A: 

Pardon my ignorance on not knowing things of XPath2.

Could you not use XPath criteria using the date value from VB instead?
I mean, "/Date > 9/9/2009" - where 9/9/2009 is the current date and that comes from VB.

Let me know, if I have not understood the question.

shahkalpesh
+1 I've been asking myself the same question.
Tomalak
+2  A: 

No, There is no Microsoft implementation (to my knowledge) of XPath 2.0.

Dimitre Novatchev
A: 

While Dimitre's answer is still perfectly valid, unfortunately (see also this thread), if you can use .NET libraries with your VBA application, you could consider using Saxon for .NET, which is a direct IKVM port of the Java Saxon to .NET.

Abel
A: 

Altova offers its XSLT and XPath 2.0 and XQuery 1.0 processor as a download for Windows, see http://www.altova.com/altovaxml.html. It is a COM application that can be scripted/automated so you should be able to use it with VBA, an example is in the documentation. I don't think there is an API to use pure XPath 2.0 but there is an API to use XQuery 1.0 and XPath 2.0 is a subset of XQuery 1.0.

Martin Honnen