I'm no xpath expert, but it seems like none of these 3 programs are giving the right results in all test cases - and these test cases are just taken from an introductory xpath article!
Also, the programs frequently don't give the same results - even though the python script is a pretty direct translation of the C program.
For each xpath expression, attempt to fetch the relevant values using 3 different programs:
/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
/data/buildroot/cruise/checkout/3.1.3-dev/xpath: bookstore.xml: no match for bookstore/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 2 selects the root element bookstore: /bookstoreHarry Potter 29.99 Learning XML 39.95
Harry Potter 29.99 Learning XML 39.95/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter 29.99 Learning XML 39.95/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 3 selects all book elements that are children of bookstore: bookstore/bookHarry Potter 29.99 Learning XML 39.95
/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
/data/buildroot/cruise/checkout/3.1.3-dev/xpath: bookstore.xml: no match for bookstore/book/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 4 selects all book elements no matter where they are in the document: //book-- NODE -- Harry Potter 29.99 Learning XML 39.95
Harry Potter 29.99/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter 29.99 Learning XML 39.95/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 5 selects all book elements that are descendant of the bookstore element, no matter where they are under the bookstore element: bookstore//book-- NODE -- Harry Potter 29.99 Learning XML 39.95
/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
/data/buildroot/cruise/checkout/3.1.3-dev/xpath: bookstore.xml: no match for bookstore//book/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 6 selects all attributes that are named lang: //@lang-- NODE -- Harry Potter 29.99 Learning XML 39.95
eng/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
eng eng/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE -- lang="eng"-- NODE -- lang="eng"xpath expression number 7 selects the first book element that is the child of the bookstore element.: /bookstore/book[1]
Harry Potter 29.99/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter 29.99/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 8 selects the last book element that is the child of the bookstore element: /bookstore/book[last()]Harry Potter 29.99
Learning XML 39.95/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Learning XML 39.95/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 9 selects the last but one book element that is the child of the bookstore element: /bookstore/book[last()-1]Learning XML 39.95
Harry Potter 29.99/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter 29.99/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 10 selects the first two book elements that are children of the bookstore element: /bookstore/book[position()<3]Harry Potter 29.99
Harry Potter 29.99/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter 29.99 Learning XML 39.95/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 11 selects all the title elements that have an attribute named lang: //title[@lang]-- NODE -- Harry Potter 29.99 Learning XML 39.95
Harry Potter/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter Learning XML/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 12 selects all the title elements that have an attribute named lang with a value of 'eng': //title[@lang='eng']Harry Potter -- NODE --Learning XML
Harry Potter/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Harry Potter Learning XML/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 2 nodes: -- NODE --xpath expression number 13 selects all the book elements of the bookstore element that have a price element with a value greater than 35.00: /bookstore/book[price>35.00]Harry Potter -- NODE --Learning XML
Learning XML 39.95/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Learning XML 39.95/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --xpath expression number 14 selects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00: /bookstore/book[price>35.00]/titleLearning XML 39.95
Learning XML/data/buildroot/cruise/checkout/3.1.3-dev/xpath (my translation of Liam's program into python):
Learning XML/usr/bin/xpath (A perl script that appears to come with openSUSE 10.3):
Found 1 nodes: -- NODE --Learning XML
You can e-mail the author with questions or comments: