Home Search

DriveWorks Pro 22
XPathXMLGet

Send Feedback

XPathXMLGet

Finds the value at a given path in an XML string.

Syntax

XPathXMLGet([Input Data],[Path])

Where:

Input Data is the input data on which to search.

Path is the path to find in the given data object.

Examples

Example XML Data being returned to the constant DWConstantXML

            <?xml version="1.0" encoding="UTF-8"?>
            <bookstore>
                 <book>
                    <title lang="en">Harry Potter</title>
                   <price>29.99</price>
                </book>
                <book>
                    <title lang="xml">Learning XML</title>
                    <price>39.95</price>
                    <difficulty>Easy</difficulty>
                   <category>Programming</category>
                </book>
            </bookstore>
RuleMeaning
XPathXMLGet(DWConstantXML,"/bookstore/book")Will return...
<book>
    <title lang="en">Harry Potter</title>
    <price>29.99</price>
</book>
<book>
    <title lang="xml">Learning XML</title>
    <price>39.95</price>
    <difficulty>Easy</difficulty>
    <category>Programming</category>
</book>
                    
XPathXMLGet(DWConstantXML,"/bookstore/book[1]")Will return...
<book>
    <title lang="en">Harry Potter</title>
    <price>29.99</price>
</book>
                    

Example Using Text()

Embedding the Text() function withing the path string will return just the values of the element:

RuleMeaning
XPathXMLGet(DWConstantXML, "/bookstore/book/price/text()")Will return 29.99|39.95.

This is a pipe delimited list of price element values within all book elements.

XPathXMLGet(DWConstantXML, "/bookstore/book[2]/price/text()")Will return 39.95.

This is the price element value within the second ([2]) book element.


See also

This function relates to the Send HTTP Request task.

XPathGet

XPathJsonGet