This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Helpful XPath API's
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
The XPath package in VisualWorks was made for their XSLT library. They've been doing work on it. I fixed a couple of bugs in it about a year ago now and published them to public store too. I think some of them got accepted, it's hard to tell :)
But today I published a new version to public store that includes an easy to use API for matching nodes in your DOM tree using XPath:
anXMLNode xpathLocate: '//foo/baz[2]/bar/text()'
It's that simple now. As simple as it should be in fact. You can pass it a string or you can pass it a pre-built XPath expression. You can pre-build the XPath expression like so:
'//foo/baz[2]/bar/text()' asXPathLocation
You can also pass in variables for the XPath expression like so: