0

Hi!
I want to find the xpath of an xml doument along with its index value in java. I'm using DOM parser to parse the xml document.

Suppose if i consider this xml document,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE folks SYSTEM "sample.dtd">
<folks>
<person>
<name>abi</name>
<phone>999555-8888</phone>
<email>b@xyz.net</email>
</person>
<person>
<name>saran</name>
<phone>213545697</phone>
<email>bbb@abc.com</email>
</person>
<person>
<name>priya</name>
<phone>33333</phone>
<email>xxxx@xyz.com</email>
</person>
</folks>

I have found the xpath of this document as,

/folks
/folks/person
/folks/person/name
/folks/person/phone
/folks/person/email
/folks/person
/folks/person/name
/folks/person/phone
/folks/person/email
/folks/person
/folks/person/name
/folks/person/phone
/folks/person/email

I should find the xpath as
/folks[1]
/folks[1]/person[1]
/folks[1]/person[1]/name[1]
/folks[1]/person[1]/phone[1]
/folks[1]/person[1]/email[1]
/folks[1]/person[2]
/folks[1]/person[1]/name[2]
and so on....
so that i can add a node in the exact position i want.

Any help Appreciated.

Thanks in Advance.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by indu_ss4
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.