Skip to content

Parse

Parses the specified string as an XML node and returns the document element as an Xml instance.

1
myXml.Parse(xml: string):Xml

Parameters

string xml
    XML string to parse.

Returns

An Xml instance representing the parsed XML.

Remarks

Whitespace is preserved during XML parsing. The returned node is not attached to the current document. XPath expressions on it are relative to the parsed document element.

Examples

Parse an XML string and read values

1
2
3
var response = $Xml.Parse('<Result><Status>OK</Status><Code>200</Code></Result>');
var status = response.Evaluate('Status');                 // 'OK'
var code = response.EvaluateNumber('Code');               // 200

Parse XML and copy it into the pool data

1
2
var customer = $Xml.Parse('<Customer><Name>John Smith</Name><Email>[email protected]</Email></Customer>');
customer.Copy('.', $Xml.SelectSingle('Customer'));

See Also