get value from XML()

This function returns the first result value of the XPath expression b on the XML object a. Optionally, an XPath expression can be created from the values b and c. Also, it is possible to set specific namespaces using a map, which can be defined in parameter d. Existing namespaces with the same name will be replaced. If a list name is specified in e, all values returned by the XPath query are added to the list. The first value of the XPath query is returned. Values previously stored in the list are not deleted. A default list name is not used if no list name is provided.

Parameters


Parameter

Description

a

Name of XML object. You can obtain such an object by using the functions parse XML() or convert JSON to XML().

b

XPath expression (Selection of a specific set of nodes).

c

(optional) XPath expression.

d

(optional) Name of the map for the namespace management.

e

(optional) Name of the list to store XPath query results into. Default: empty.


Example 1


Given is the following XML file, which we first read in under the name "xml_Invoice" with function "parse XML()". We can then use this name in parameter a of this function here.


Invoice.xml
<Invoice>
<Invoice_number>INV_12345</Invoice_number>
<Invoice_date>2014-05-21T15:25:11Z</Invoice_date>
<Customer>
<Customer_number>12345</Customer_number>
<First_name>Gustav</First_name>
<Last_name>Thalmeier</Last_name>
<City>Treuchtlingen</City>
<DOB>15.07.1981</DOB>
<Order>
<Article_number id="123689">DE459363258</Article_number>
<Quantity>1</Quantity>
<Price>17,98</Price>
</Order>
<Order>
<Article_number id="5896324">459363298</Article_number>
<Quantity>1</Quantity>
<Price>4,99</Price>
</Order>
</Customer>
<Customer>
<Customer_number>85639</Customer_number>
<First_name>Henriette</First_name>
<Last_name>Michlmeier</Last_name>
<City>Breckerfeld</City>
<DOB>04.12.1975</DOB>
<Order>
<Article_number id="9832475">DE459362358</Article_number>
<Quantity>1</Quantity>
<Price>199,59</Price>
</Order>
<Order>
<Article_number id="123659">459363258</Article_number>
<Quantity>3</Quantity>
<Price>7,99</Price>
</Order>
<Order>
<Article_number id="123689">DE459363258</Article_number>
<Quantity>1</Quantity>
<Price>14,99</Price>
</Order>
</Customer>
</Invoice>


If a list name is specified in parameter e, we assume the list to be empty.


Parameter a

Parameter b

Parameter c

Parameter d

Parameter e

Result

Elements of the list

xml_Invoice

/NonExist






xml_Invoice

/Invoice[1]/Invoice_date




2014-05-21T15:25:11Z


xml_Invoice

/Invoice_number

/Invoice[1]



INV_12345


xml_Invoice

/Invoice[1]/Customer[1]/Customer_number




12345

12345

xml_Invoice

/Invoice[1]/Customer[2]/Customer_number




85639


xml_Invoice

//Customer_number




12345


xml_Invoice

//Customer_number



custList

12345

12345, 85639


Example 2


Given is the following XML file, which we first read in under the name "xml_ConversionRate" with function "parse XML()". We can then use this name in parameter a of this function here.


ConversionRate.xml
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:conversionrate="http://www.example.com">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>309.09</ConversionRateResult>
<ConversionRateResult>22.15</ConversionRateResult>
<conversionrate:Date>2017-04-03</conversionrate:Date>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>


Note: To be able to use the value of tag "ConversionRateResult", a map with the namespace "dw_dflt=http://www.webserviceX.NET/" has to be defined. To find results, the XPath expression has to use the respective prefix.

The map can be used to simplify namespace names.

Assume the following map for the examples:

dw_dflt=http://www.webserviceX.NET/

cr=http://www.example.com

s=http://www.w3.org/2003/05/soap-envelope


Parameter a

xml_ConversionRate

Parameter b

/NonExist

Parameter c


Parameter d


Parameter e


Result


Elements of the list


Parameter a

xml_ConversionRate

Parameter b

/Envelope[1]/Body[1]/ConversionRateResponse[1]/ConversionRateResult

Parameter c


Parameter d


Parameter e


Result

Empty (see note above)

Elements of the list


Parameter a

xml_ConversionRate

Parameter b

/soap:Envelope[1]/soap:Body[1]/ConversionRateResponse[1]/ConversionRateResult

Parameter c


Parameter d


Parameter e


Result

Empty (see note above)

Elements of the list


Parameter a

xml_ConversionRate

Parameter b

/soap:Envelope[1]/soap:Body[1]/dw_dflt:ConversionRateResponse[1]/dw_dflt:ConversionRateResult[1]

Parameter c


Parameter d

map_namespaces

Parameter e


Result

309.09

Elements of the list


Parameter a

xml_ConversionRate

Parameter b

//dw_dflt:ConversionRateResult

Parameter c


Parameter d

map_namespaces

Parameter e


Result

309.09

Elements of the list


Parameter a

xml_ConversionRate

Parameter b

/dw_dflt:ConversionRateResponse[1]/dw_dflt:ConversionRateResult

Parameter c

/soap:Envelope[1]/soap:Body[1]

Parameter d

map_namespaces

Parameter e

list_ConversionRate

Result

309.09

Elements of the list

309.09,22.15

Parameter a

xml_ConversionRate

Parameter b

/soap:Envelope[1]/soap:Body[1]/dw_dflt:ConversionRateResponse[1]/conversionrate:Date[1]

Parameter c


Parameter d


Parameter e


Result

2017-04-03

Elements of the list


Parameter a

xml_ConversionRate

Parameter b

/s:Envelope[1]/s:Body[1]/dw_dflt:ConversionRateResponse[1]/cr:Date

Parameter c


Parameter d

map_namespaces

Parameter e


Result

2017-04-03

Elements of the list


Please note that in the case of XML files with namespaces, the namespace must also be specified in the XPath expression.