Was this page helpful?

Xml.Select

    Table of contents
    1. 1. Usage Restrictions
    2. 2. Parameters
    3. 3. Result
    4. 4. Samples
    xml.Select(doc : xml, xpath : str, namespace : map?) : xml
    

    Create an XML selection using an xpath.

    Normally the first matching XML element is returned; however, a complete list of matching elements may be accessed in a foreach statement.  If no match is found, then nil is returned.

    Note that Xml.Select(doc, xpath) is equivalent to doc[xpath].  The only difference is that Xml.Select allows XML namespaces to be defined for the XPath expression. 

    Usage Restrictions

    1.9.1 or later

    Parameters

    Name Type Description
    doc xml XML document
    xpath str XPath expression for selection
    namespaces map (optional, default:none) XML namespaces to use for XPath expression

    Result

    An XML value from an XML document (or list of values is used in a foreach statement) or nil if no elements matched the XPath expression.

    Samples

      Output

    get the first <title> element in the API XML document for this page:

    {{ xml.format(xml.select(wiki.api(page.api), "//title")) }} 

     

    <title>Xml.Select</title>

    get a list of all <title> elements in the API XML document for this page (requires 9.02 or later):

    {{ [ t foreach var t in xml.select(wiki.api(page.api), "//title") ] }} 

     

    [ <title>"Xml.Select"</title>, <title>"DekiScript Functions and Variables"</title>, <title>"Reference"</title>, <title>"DekiScript"</title>, <title>"Documentation"</title>, <title>"MindTouch Community Portal"</title>, <title>"MindTouch Community Portal"</title> ]

     

    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by