Man illustrationFlower illustration
Xml and JSON

Execute xpath

Estimated reading: 6 minutes 388 views

Execute xpath activity allows reaching the location of each element or attribution in the .xml file via Xpath and getting desired values.


*File nameThe XML file name is written.
*Xml stringIf any result is received as an XML string (Not a file with XML content) XML content is written. The other fields, prefixes, etc. XML is written to parse the content. Then, it is ensured that operations can be performed as a dataset.

Note: If this field is used, the File name field does not need to be used.
*Xpath expressionThe Xpath of which element/attribute to be referenced is referenced and the information related to element or attribute is selected by using Filter field.
*FilterThe information type (element/attribute) to be accessed within Xpath is entered. In the dropdown menu, two information types (element/attribute) can be selected.
PrefixThis is the area where prefixes are defined when using the elements in the XML file. In case more than one prefix is needed, other prefix fields are filled.
UriTo define the first prefix, the URI of the prefix is provided here.
Prefix2This is the area where prefixes are defined when using the elements in the XML file.
Uri2To define prefix2, the URI of the prefix is provided here.
Prefix3This is the area where prefixes are defined when using the elements in the XML file.
Uri3To define the first prefix3, the URI of the prefix is provided here.
*Output datasetA dataset name is written for the XPath execution result.
DelimiterThe delimiter is used to separate the Xpaths when more than one Xpath is used.
Note: * Fields selected with are required, others are optional

You can use the File name as shown in the example.

C:\UsersAliceDocumentsinvoice.xml

You can use the Xml string as shown in the example.

<string name=”string_name” text_string </string

You can use the Xpath expressions shown in the example.


<? Xml version = “1.0” encoding = “UTF-8”?>
<Invoice>
<Return_ID>135672</Return_ID>
<Store_ID>23465</Store_ID>
<Store_Name>BELGE</Store_Name>
<Supplier_Name>Third Part Company</Supplier_Name>
<Supplier_Account_No>7330028047</Supplier_Account_No>
<Brand_ID>14235</Brand_ID>
</Invoice>
Let’s consider a file with .xml extension that has XML content in this way. Let’s want to access the Store_ID element in the tree structure in the file. The Xpath Statement to be written for this would be as follows:

//Invoice/Store_ID

You can use the Filter as shown in the example.

ELEMENT

Let’s use the XPath specified in the example above. This Xpath takes us to the Store_ID element in the tree structure. That is, the address of an element to be reached with XPath. Thus, ELEMENT is selected from the combobox.

You can use the Prefix shown in the example.

ds:Reference

Based on the XML file content above, this field is not filled because there is no prefix for the elements in the .xml file. The prefix is specified in an xml file as follows:
<ds:Reference Id=”Reference-Id-28eeffb3-146c-4a8a-9e12-19541d39ee0e” URI=””>. The prefix of the Reference element in this expression is ‘ds’.

You can use the Prefix2 shown in the example.

cac:AdditionalDocumentReference

Based on the XML file content above, this field is not filled because there is no prefix for the elements in the .xml file. The As in the above mentioned ‘Prefix’ example, if there is another prefix like “ds”, a prefix is written in this field again. Xpath information also varies according to usage.
<cac:AdditionalDocumentReference>
<cbc:ID>0.00</cbc:ID>
<cbc:IssueDate>2020-03-18</cbc:IssueDate>
<cbc:DocumentType>ALLOWANCETOTALAMOUNT</cbc:DocumentType>
</cac:AdditionalDocumentReference>
As can be seen in this example, different prefixes (prefixes) can be included in the .xml file.

You can use the Prefix3 shown in the example.

caa:Username

Suppose that the file specified in the prefix2 example also has a field like the following:
<caa:Username>john.smith</cbc:DocumentType>
If you want to reach this field in the XML file, in addition to the cac and cbc prefixes, the caa prefix is also introduced in this field; Prefix3: becomes caa.

You can use the URI as shown in the example.

urn: oasis: names: specification: ubl: schema: xsd: CommonAggregateComponents-2

The prefix contains Uri information in the .xml file.
xmlns: cac = “urn: oasis: names: specification: ubl: schema: xsd: CommonAggregateComponents-2”, the area to the left of the equation and in quotes contains the Uri information. When writing the expression Uri, the part between the double quotes is written:
It is shown as urn: oasis: names: specification: ubl: schema: xsd: CommonAggregateComponents-2.

You can use the URI2 as shown in the example.

urn: oasis: names: specification: ubl: schema: xsd: CommonAggregateComponents-2

The prefix contains Uri information in the .xml file.
The field specified in the expression xmlns: ext = “urn: oasis: names: specification: ubl: schema: xsd: CommonExtensionComponents-2”, to the left of the equation, and in quotes contains the Uri information. When writing the expression Uri, the part between the double quotes is written:
It is shown as urn: oasis: names: specification: ubl: schema: xsd: CommonExtensionComponents-2.

You can use the URI3 as shown in the example.

urn: oasis: names: specification: ubl: schema: xsd: CommonAggregateComponents-2

or Prefix3 defined above, Uri information similar to Uri and Uri2 is written in the specified format.

You can use the Output dataset as shown in the example.

outputvalue

You can use the Delimiter as shown in the example.

If a single xpath is used, the Delimiter must not be filled.

If using multiple xpaths;

The sign separating the xpaths must be entered in the Delimiter field.

If xpaths are separated by “,”

,

Single Xpath

  • The value in the xml is not transferred to the dataset. This value is taken as an element.
  • And this value can only be retrieved with “XML and Json > Get Value”.

More than one Xpath

  • Each given xpath is taken as the header and the values ​​are written explicitly line by line.

Share this Doc

Execute xpath

Or copy link

CONTENTS
Chat Icon Close Icon