Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi...
Please anybody can tell how to get the full path of an xml node which I obtained with getElementsByTagName() function.With this function I got a list of nodes of specified name.Now I want to iterate each node and I need to get the full path of each node.How can I get the path....
Posted

1 solution

This is very simple.

In a loop, get Node.parentNode until document node is reached. One way of doing this is checking Node.nodeType; the loops ends when nodeType == Document; another way is checking the condition of null parent node.

To get a full path concatenate the values of Node.nodeName on the left side of the current path with some delimiter between nodeName values.

—SA
 
Share this answer
 
Comments
Jijesh Balakrishnan 25-Apr-11 0:14am    
Thank you for your reply... Thanks a lot
Sergey Alexandrovich Kryukov 25-Apr-11 0:21am    
You're welcome.
Is it enough for you to formally accept this answer?
Thank you.
--SA
Jijesh Balakrishnan 25-Apr-11 0:38am    
ya sure....
Sergey Alexandrovich Kryukov 25-Apr-11 0:55am    
I mean the green button "Accept". If you agree with the answer, of course... :-)
--SA
Jijesh Balakrishnan 29-Apr-11 5:07am    
sry for late accept

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900