Happy !
hernan / XPath
About XPath
Description
A basic XPath library for Squeak and Pharo, leveraging the XML parsing capabilities now included in the base image. Modifies XMLNode to better support XPath. Handles basic XPath locator expressions for elements and attributes; returns a collection of XMLNodes matching the expression, if any.
Examples
Example 1
| xml doc |
xml := '<root>
<topChild/>
</root>'.
doc := XMLDOMParser on: xml.
(XPath for: 'root/topChild') in: doc parseDocument
Example 2
| xml doc |
xml := '<?xml version="1.0" encoding="UTF-8" ?>
<first>
<second>
<item type="attvalue">nodevalue</item>
</second>
</first> '.
doc := XMLDOMParser on: xml.
(XPath for: 'first') in: doc parseDocument
Example 3
| doc |
doc := (XMLDOMParser onURL: 'http://unicode.org/repos/cldr/trunk/common/supplemental/supplementalData.xml') parseDocument.
(XPath for: '/languageData/language/@type') in: doc.
