Home Search

DriveWorks Pro 21
SppXPathSetElementValue

Send Feedback

SppXPathSetElementValue

Returns an XML formatted object with elements set either individually or loaded from an array (such as a data table).

Syntax

SppXPathSetElementValue([XML],[Element Path],[New Element Name],[Value])

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\Customer). If the element is part of an Array with the same name, the path would need to use an instance number (for example Quote\Customer[6] to return the value for the sixth item. Element Path is case sensitive.

New Element Name is the new name for the element whose values are set when loaded from an Array. (Not applicable when using a string to set a value.)

Value is the new value for the element. This can be a string or Table Array. If a Table Array is used to add multiple elements with children (one child for each row), then the element name of each child is set to the value entered for New Element name.

Example

RuleResultMeaning
SppXPathSetElementValue(DWVariableXMLLoad,"Catalog\Item[1]\Price",,"15.00")See below for example data and an example result.Will return an Array with a new value inserted for the given element path.

Example XML

An example XML file showing a Catalog of engineering fastenings.

<?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>
        

Example Result

Example result showing the produced Array of XML with the price change for the second Item in the catalog.

{"<Catalog lang=""eng"">
    <Item>
      <Name>M6 Nylock Nuts x100</Name>
      <Price>15.00</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>"}