extract xml(a,b,c,d)


This function can extract a part from an XML file a, which is defined by the XPath expression b.

If more than one element is supplied by the XPath expression, only the first element is used.

Parameter Description


Parameter

Description

a

Name of the XML DOM object or XML as text. If no DOM object is found, the parameter value is interpreted as text. Note: See also function parse XML( a, b, c ).

b

The XPath expression.

c

(optional) If true, errors are ignored. Default: false.

d

(optional) If true, the XML declaration in the result XML is omitted. Default: false.

Example


Let's assume the following XML file, which you specify in parameter a either directly or via the DOM object you previously read in using function parse XML( a, b, c ).


<?xml version="1.0"?>
<customers>
<customer id="55000">
<name>Charter Group</name>
<address>
<street>100 Main</street>
<city>Framingham</city>
<state>MA</state>
<zip>01701</zip>
</address>
<address>
<street>720 Prospect</street>
<city>Framingham</city>
<state>MA</state>
<zip>01701</zip>
</address>
<address>
<street>120 Ridge</street>
<state>MA</state>
<zip>01760</zip>
</address>
</customer>
</customers>


In parameter b we use the XPath expression //customers/customer/address

We leave parameters c and d empty.

As a result, we then get the following XML.


<?xml version="1.0" encoding="UTF-8"?>
<address>
<street>100 Main</street>
<city>Framingham</city>
<state>MA</state>
<zip>01701</zip>
</address>