This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes Need help with XPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Need help with XPATH" Watch "Need help with XPATH" New topic

Need help with XPATH

Rudolf Castelino

Joined: Oct 30, 2002
Posts: 18
I am creating an xml document of the structure
</main >
I need to locate a sub1 node with a specific value. What should the xpath be.
I know it should be //main/sub/sub1?
Please help
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Please check this tutorial first
See whether you can solve the problem, if not please post back.
if not see below
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:template match="/">
<xsl:value-of select="/*/sub/sub1[1]"/>
<xsl:value-of select="/*/sub/sub1[2]"/>
<xsl:value-of select="/*/sub/sub1[3]"/>
Read the above linked tutorial to learn using xsl:for-each

Spritle Software Blogs
Rudolf Castelino

Joined: Oct 30, 2002
Posts: 18
Thanks for the input. I had already checked the link, prior to posting this query.
The solution was fairly simple, i got it after a few minutes after posting the question.
I agree. Here's the link:
subject: Need help with XPATH