| View previous topic :: View next topic |
| Author |
Message |
Kishore Contributing Member

Joined: 20 Feb 2007 Posts: 200 Location: Banglore , India
|
Posted: Wed Feb 21, 2007 1:01 pm Post subject: Looping through nodes using XPath command |
|
|
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 |
|
 |
Daniel Contributing Member

Joined: 14 Feb 2007 Posts: 207
|
Posted: Mon Feb 26, 2007 1:13 pm Post subject: |
|
|
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 |
|
 |
N Hunter Junior Member

Joined: 20 Jun 2007 Posts: 2
|
Posted: Thu Jun 21, 2007 8:37 am Post subject: |
|
|
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 |
|
 |
Kishore Contributing Member

Joined: 20 Feb 2007 Posts: 200 Location: Banglore , India
|
Posted: Thu Jun 21, 2007 9:04 am Post subject: |
|
|
Thanks N Hunter. I had done this. But your code is easy to understand. I will follow this next time. _________________ =================
Kish |
|
| Back to top |
|
 |
Robel2008 Junior Member

Joined: 23 Feb 2009 Posts: 1
|
Posted: Mon Feb 23, 2009 8:17 pm Post subject: What is servlet filtering |
|
|
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 |
|
 |
|