dev-exchange.com logo

dev-exchange.com topic RSS feed

Book mark: Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your delicious account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your digg account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your blinklist account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your reddit account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to Dzone Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your furl account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your stumble account Add http://www.dev-exchange.com/viewtopic.php?t=81&start=0&postdays=0&postorder=asc&highlight= to your Yahoo myweb account
Looping through nodes using XPath command

 
Post new topic   Reply to topic   printer-friendly view    dev-exchange.com Forum Index -> XML-XSLT
View previous topic :: View next topic  
Author Message
Kishore
Contributing Member
Contributing Member


Joined: 20 Feb 2007
Posts: 200
Location: Banglore , India

PostPosted: Wed Feb 21, 2007 1:01 pm    Post subject: Looping through nodes using XPath command Reply with quote

Hi,


Please tell me how do i loop through the following XML data using XPATH command.

Any help would be greatly appreciated

Code:
<CDs>
        <CD id="1">
                <TITLE>title 1</TITLE>
                <PRICE>$10</PRICE>
         </CD>
                 <CD id="2">
                <TITLE>title 2</TITLE>
                <PRICE>$15</PRICE>
         </CD>
</CDs>




Thanks
_________________
=================
Kish
Back to top
View user's profile Send private message
Daniel
Contributing Member
Contributing Member


Joined: 14 Feb 2007
Posts: 207

PostPosted: Mon Feb 26, 2007 1:13 pm    Post subject: Reply with quote

You can do something like this. i havent tested this. Play around with this you will get the result what you are looking for.

Code:

<xsl:for-each select="//CDs/CD/">
<xsl:value-of select="@Title"/> - <xsl:value-of select="@Price"/> <Br />
</xsl:for-each>
Back to top
View user's profile Send private message
N Hunter
Junior Member
Junior Member


Joined: 20 Jun 2007
Posts: 2

PostPosted: Thu Jun 21, 2007 8:37 am    Post subject: Reply with quote

I'm sure you've solved this one but for completeness here is an example:


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="CDs">
<xsl:for-each select="CD">
<div><xsl:value-of select="@id"/> , <xsl:value-of select="TITLE"/> , <xsl:value-of select="PRICE"/></div></xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Back to top
View user's profile Send private message
Kishore
Contributing Member
Contributing Member


Joined: 20 Feb 2007
Posts: 200
Location: Banglore , India

PostPosted: Thu Jun 21, 2007 9:04 am    Post subject: Reply with quote

Thanks N Hunter. I had done this. But your code is easy to understand. I will follow this next time.
_________________
=================
Kish
Back to top
View user's profile Send private message
Robel2008
Junior Member
Junior Member


Joined: 23 Feb 2009
Posts: 1

PostPosted: Mon Feb 23, 2009 8:17 pm    Post subject: What is servlet filtering Reply with quote

XSL/T transformations of XML content-Targeting web application responses to more
that .... XSLT is a language for transforming XML data. You can use XSLT to .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    dev-exchange.com Forum Index -> XML-XSLT All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


© 2008 dev-exchange.com
Powered by phpBB. Theme DEVPPL.