Home Search

DriveWorks Pro 22
SppXPathGetElementValue

Send Feedback

SppXPathGetElementValue

Returns a single value for a specified element in an XML value.

If the element itself has children, then an Array of the child data will be returned.

Syntax

SppXPathGetElementValue([XML],[Element Path],[Result as XML],[Show Siblings])

Where:

XML is an XML object such as that returned value from SppXMLFromString or SppXMLLoad, or XML as a text string.

Element Path is a full path to the element inside the XML object (for example; Quote\Items). If the element is part of an Array with the same name, the path will need to use an instance number (for example; Quote\Items[2] to return the value for the second item). Element Path is case sensitive.

Result as XML is TRUE to show the result in XML format, if the result is itself an element or Array of elements. FALSE to show the result as a value or Array value.

Show Siblings is TRUE to show values for all elements of the same name, FALSE to return the first instance of the element.

Example

RuleResultMeaning
SppXPathGetElementValue(DWVariableXMLLoad,"Catalog\Item[2]",FALSE,TRUE){"Name","Value";"Name","M8 Nylock Nuts x100";"Price","15.30";"Description","Bag of 100 Self-locking nuts with glass-filled nylon inserts";"Stock","39"}Will return an Array showing specified element children for a given element path.

Example XML

This example shows a Catalog as a XML file.

<?xml version="1.0" encoding="UTF-8"?>
<Catalog lang="eng">
  <Item>
    <Name>M6 Nylock Nuts x100</Name>
    <Price>12.50</Price>
    <Description>Bag of 100 Self-locking nuts with glass-filled nylon inserts</Description>
    <Stock>50</Stock>
  </Item>
  <Item>
    <Name>M8 Nylock Nuts x100</Name>
    <Price>15.30</Price>
    <Description>Bag of 100 Self-locking nuts with glass-filled nylon inserts</Description>
    <Stock>39</Stock>
  </Item>
  <Item>
    <Name>M10 Nylock Nuts x100</Name>
    <Price>18.10</Price>
    <Description>Bag of 100 Self-locking nuts with glass-filled nylon inserts</Description>
    <Stock>72</Stock>
  </Item>
  <Item>
    <Name>M6 x 40mm Stainless Steel Hex Bolt x50</Name>
    <Price>16.60</Price>
    <Description>Box of 50 M6 x 40mm Stainless Steel Hex Bolts</Description>
    <Stock>28</Stock>
  </Item>
  <Item>
    <Name>M8 x 40mm Stainless Steel Hex Bolt x50</Name>
    <Price>22.40</Price>
    <Description>Box of 50 M8 x 40mm Stainless Steel Hex Bolts</Description>
    <Stock>16</Stock>
  </Item>
</Catalog>