aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Need help with XPATH" Watch "Need help with XPATH" New topic
Author

Need help with XPATH

Rudolf Castelino
Greenhorn

Joined: Oct 30, 2002
Posts: 18
Hi
I am creating an xml document of the structure
<main>
<sub>
<sub1>value</sub1>
<sub1>value<sub1>
<sub1>value</sub1>
</sub>
</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
Regards
Rudolf
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Please check this tutorial first http://www.w3schools.com/xsl/default.asp
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="http://www.w3.org/1999/XSL/Transform" 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]"/>
</xsl:template>
Read the above linked tutorial to learn using xsl:for-each


Spritle Software Blogs
Rudolf Castelino
Greenhorn

Joined: Oct 30, 2002
Posts: 18
Hi
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.
thanks
Rudolf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with XPATH