The XPath utility component evaluates XPath expressions on instances of XMLObject.
xmlString =
"<?xml version='1.0' encoding='utf-8'?>\n"+
" <bookstore>\n"+
" <book category='WEB'>\n"+
" <title lang='en'>XQuery Kick Start</title>\n"+
" <author>James McGovern</author>\n"+
" <author>Per Bothner</author>\n"+
" <author>Kurt Cagle</author>\n"+
" <author>James Linn</author>\n"+
" <author>Vaidyanathan Nagarajan</author>\n"+
" <year>2003</year>\n"+
" <price>49.99</price>\n"+
"</book>\n"+
"<book category='WEB'>\n"+
" <title lang='en'>Learning XML</title>\n"+
" <author>Erik T. Ray</author>\n"+
" <year>2003</year>\n"+
" <price>39.95</price>\n"+
"</book>\n"+
"</bookstore>\n"
xmlObject = XMLObject(xmlString)
// Select the first book node under the bookstore element:
books = XPath.evaluate(xpath : "/bookstore/book[1]",
context : xmlObject)
// Selecting book nodes for those priced over $35
overPriced = XPath.evaluate(xpath : "/bookstore/book[price>35]/price",
context : xmlObject)