Skip to content

Xml

Represents an XML navigator that enables selection and modification of XML nodes.

Remarks

XPath expressions are evaluated relative to the current node. Prefer relative paths such as Customer/Name over descendant searches such as //Name; descendant searches scan the whole document and can match nodes outside the part of the data model that the script owns.

The same interface is available in server scripts and in browser form scripts, but a few members exist on only one side. Their remarks state where they are available.

The examples on this page use the following pool data, with $Xml pointing to the Order element:

Examples

Sample order data

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<Order>
  <Id>1001</Id>
  <Customer>
    <Name>Jane Doe</Name>
    <Email>[email protected]</Email>
  </Customer>
  <Lines>
    <Line>
      <Product>Pen</Product>
      <Quantity>2</Quantity>
      <Price>1.5</Price>
    </Line>
    <Line>
      <Product>Notebook</Product>
      <Quantity>1</Quantity>
      <Price>4</Price>
    </Line>
  </Lines>
  <Total></Total>
  <Approved>false</Approved>
  <DueDate>2026-01-31T17:00:00+03:00</DueDate>
</Order>

Read, calculate and update order data

1
2
3
4
5
6
7
8
9
var customerName = $Xml.Evaluate('Customer/Name');            // 'Jane Doe'
var lineCount = $Xml.Count('Lines/Line');                      // 2
var total = 0;

$Xml.SelectAll('Lines/Line', function (line) {
    total += line.EvaluateNumber('Quantity') * line.EvaluateNumber('Price');
});

$Xml.SetValue('Total', total);                                // 7

Capabilities

Namespaces

Structure Changes

  • Xml.AppendChild: Appends a new child to the specified XPath location and executes the provided callback function on the newly created node before inserting it into the DOM. Returns the appended new node.
  • Xml.Clone: Creates a detached deep copy of the current node.
  • Xml.Copy: Copies the current XML node and all its child nodes from the source XPath to the target XPath or target navigator.
  • Xml.Remove: Removes the current node and returns it in an array.
  • Xml.Sync: Synchronizes the nodes at the specified XPath with the input nodes, and returns an array of the synchronized nodes.

Validation and Cleanup

  • Xml.Assert: Performs an error check by asserting that the specified XPath evaluates to a boolean true value. If the assertion fails, an error is thrown.
  • Xml.CommitDeletes: Deletes all child nodes that have the State attribute set to the value 'Deleted'.

Client Events

  • Xml.Bind: Attaches a change event handler to the nodes selected by the specified XPath.
  • Xml.Live: Attaches a change event handler to the specified XPath.
  • Xml.Trigger: Triggers event handlers bound to the current node.

Reading and Predicates

  • Xml.Count: Returns the number of nodes at the specified XPath.
  • Xml.Equals: Returns a boolean value indicating whether the current node has the specified value.
  • Xml.Evaluate: Returns the string value of the current node.
  • Xml.EvaluateBoolean: Returns the boolean value of the current node.
  • Xml.EvaluateDateTime: Returns the date-time offset value of the current node.
  • Xml.EvaluateNumber: Returns the numeric value of the current node.
  • Xml.IsEmpty: Returns a boolean value indicating whether the current node has an empty string value.
  • Xml.Sum: Returns the sum of the numeric values of child elements on the current node, or at the specified XPath.

Creation and Persistence

Formatting and Transformation

  • Xml.Format: Applies the specified template to the current node and returns the resulting string.
  • Xml.FormatAll: Applies the specified template to every node selected by the XPath and joins the results with a separator.
  • Xml.InnerXml: Returns the inner XML of the current node.
  • Xml.OuterXml: Returns the outer XML of the current node.
  • Xml.Transform: Performs an XSLT transformation on the current node and returns the result as a string.

Attributes

Selection and Navigation

  • Xml.GetParent: Returns the parent node of the current node.
  • Xml.HasNode: Returns a boolean value indicating whether the specified XPath selects at least one node.
  • Xml.LocalName: Returns the local name of the current node, without its namespace prefix.
  • Xml.SelectAll: Selects all matching nodes based on the specified XPath expression.
  • Xml.SelectSingle: Selects a single node based on the specified XPath expression.

Value Updates