CONTACT US: +44 7442997XXX | info@ridhitechgroup

Xpath:

XPath is used to query selected nodes from an XML document.and used to navigate through elements and attributes in an XML document.XPath stands for XML Path Language. XPath uses “path like” syntax to identify and navigate nodes in an XML document. XPath contains over 200 built-in functions. XPath is a major element in the XSLT standard. XPathspecification specifies seven types of nodes which can be the output of execution of the XPath expression.

  • Root
  • Element
  • Text
  • Attribute
  • Comment
  • Processing Instruction
  • Namespace

XPath uses a path expression to select node or a list of nodes from an XML document.

S.No.Expression & Description
1node-name

 

Select all nodes with the given name “node name”

2/

 

Selection starts from the root node

3//

 

Selection starts from the current node that match the selection

4.

 

Selects the current node

5..

 

Selects the parent of the current node

6@

 

Selects attributes

Example

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<ns1:timeSeriesResponse>

<ns1:timeSeries>

<ns1:sourceInfo>

<ns1:siteName>XYZ</ns1:siteName>

<ns1:siteCode network=”WIS” agencyCode=”ABCD”>0124454</ns1:siteCode>

</ns1:sourceInfo>

<ns1:variable ns1:oid=”45807073″>

<ns1:variableCode network=”WIS” vocabulary=”WIS:UnitValues” default=”true” variableID=”45807073″>00020</ns1:variableCode>

<ns1:variableName>Temperature, air, &#176;C</ns1:variableName>

<ns1:variableDescription>Temperature, air, degrees Celsius</ns1:variableDescription>

<ns1:valueType>Derived Value</ns1:valueType>

<ns1:unitCode>deg C</ns1:unitCode>

</ns1:variable>

<ns1:values>

<ns1:value qualifiers=”P” dateTime=”2019-05-01T00:00:00.000-04:00″>3.1</ns1:value>

<ns1:qualifierqualifierID=”0″ ns1:network=”WIS” ns1:vocabulary=”uv_rmk_cd”>

<ns1:qualifierCode>P</ns1:qualifierCode>

<ns1:qualifierDescription>Provisional data subject to revision.</ns1:qualifierDescription>

</ns1:qualifier>

<ns1:methodmethodID=”67987″>

<ns1:methodDescription/>

</ns1:method>

</ns1:values>

</ns1:timeSeries>

</ns1:timeSeriesResponse>

In Talend, nodes can be extracted using tExtractXMLField component.