XPath

What is XPath?

Questions by rajadurai24   answers by rajadurai24

Showing Answers 1 - 6 of 6 Answers

vijusatya

  • Jun 4th, 2009
 

XPath describes where the items are located in a xml files

For Example
<employees>
<name>XYZ</name>----path for this is employees/name
<address>
<street address> 3 rd mg road </street address>---path--employees/address/street address
<city>chennai</city>
<state>tamilnadu</state>
<pincode>600007</pincode>
</addresss>
</employees>


in general the path for an element are represented by "/" and for attributes it is represented by "@"

Xpath tells where exactly a particular node is located in the XML document. Its structure(format) resembles that of a any folder structure in windows.

For e.g.
To locate a file named "Test.txt" which in folder "Docs" which is a sub-folder of "D:/", the path will be "D:/Docs/Test.txt".

Similarly in the following xml,

<Travellers>
       <Traveller>
           <TravellerType>Adult</TravellerType>
           <Count>12</Count>
           <MaxAge>35</MaxAge>
        </Traveller>
        <Traveller>
           <TravellerType>Child</TravellerType>
           <Count>6</Count>
           <MaxAge>12</MaxAge>
        </Traveller>
</Travellers>

The xpath of the node "<MaxAge>" will be : Travellers/Traveller/MaxAge

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions