Version 5 of XPath

Updated 2002-06-24 22:29:04

"XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer." That's the summary of version 1.0 of the W3C specification of the XML Path Language--XPath. You can read this standard (or "recommendation", in W3C vernacular) for yourself at http://www.w3.org/TR/xpath . One way to think about XPath is that it does for XML instances a bit of what SQL does for RDBMSs--it's a kind of query language. It complements XSLT in particular; XSLT describes what changes to make, and XPath tells where in a document to make them (very roughly).


Examples of XPath

        <html>
            <a href="http://mini.net/tcl/">Tcler's Wiki</a>
            <a href="http://tcl.activestate.com/">Tcl Exchange</a>
            <a id="getme" href="http://openacs.org/">OpenACS</a>
        </html>

Given the example XML above we could extract all <a> tags using the following XPath:

        //a

We could also grab the "OpenACS" link with the following XPath:

        //a[@id="getme"]

More examples can be found at: http://www.zvon.org/xxl/XPathTutorial/General/examples.html

JC


[Explain XPath implementations in existing Tcl-XSLT bindings.]