Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sample on how to work with XPATH

 
Ravi Doddi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai....
I have a xml file and I want to parse specific element using XPATH.
Could anyone give an sample java code that could parse an xml through XPATH.
Thankyou.
 
Tushar Madhukar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "parsing" XML, I am assuming you want to query your DOM.

JDK 1.5 comes bundled with an XPath API (pl refer to package documentation of javax.xml.xpath). It is quite easy to use, with the Javadoc itself mentioning a working example.

Regards
 
Siegfried Heintze
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Here is the output of the embedded bash script when executed with Java 1.6 on windows with cygwin installed:


[ January 20, 2008: Message edited by: Siegfried Heintze ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic