• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve XPath expression for each XML Node?

 
munar reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please could someone help me to retrieve the node names with complete hierarchy (parent child hierarchy similar to xPath expression)


The Output should be

CATALOG
CATALOG/CD[0]
CATALOG/CD[0]/TITLE

CATALOG/CD[1]
CATALOG/CD[1]/TITLE
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this issue : add XPath functionality.

If you want to parse a XML file, Android includes SAX,DOM and XMLPullParser. Take a look at this article to see how that works.

Hope that helps..
 
munar reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Monu, Does it have any function to retrieve the node names along with the parent hierarchy?

I see no such function exists in org.w3c.dom.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you parse an XML using a DOM parser, you loop through all the Nodes in a NodeList. The Node class has methods that can be used to get Node Name and name of the parent. Read the article in the above post to get an idea.
You can also refer the following:
org.w3c.dom.Node
org.w3c.dom.NodeList
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic