Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Function [other Function type actions]
Item [operators of similar scope]
Stream parsing [other Stream parsing operators]
source context dependent
v9.1.0
Baseline
As at baseline
XML.xml(pathStr)
If there is no current XML object, attempts to parse the string as XML and fails if unsuccessful. If there is a current XML object, it will be reused.
Returns a specific piece of data from the XML object, determined by the pathStr should be an expression or a quoted string.
Consider a note "Source note" with this $Text:
<shelf>
<book price="9.95">War and Peace</book>
<book price="4.95">No et Moi</book>
<audio price="14.95">Born To Run</audio>
</shelf>
Example usage of path:
$Text("test") = $Text("Source note").xml("/shelf/book");
sets $Text of note "test" to a list of children of the <shelf>
element that are <book>
elements. "War and Peace;No et Moi"
$Text("test") = $Text("Source note").$Text.xml("/shelf/book[2]")
sets $Text of note "test" to the value of child element of the <shelf>
element that represents the second book, "No et Moi". See 'Notes' below.
$Text("test") = $Text("Source note").$Text.xml("/shelf/book@price")
sets $Text of note "test" to the price
attribute of each book, "9.954.95"
Notes:
- Acceptable path content is a subset of the XPath standard (see https://www.w3.org/TR/2017/REC-xpath-31-20170321/). This explains the 'book@price' usage above to get the 'price' attribute value from a 'book' element. Explanation of XPath is out of scope for aTbRef.
- To accord with standard XML and XPath usage, the first child of an XML node is child [1], not [0].
- XML attributes are not related to Tinderbox attributes.
See also—notes linking to here: