• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with XPATH

 
Rudolf Castelino
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rudolf Castelino
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic