Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2007, 09:41 AM
Registered User
 
Join Date: Apr 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default attribute - looping

I am trying to loop thru my xml file on an attribute. My xml loops like this.

Code:
<mydata name="1" town="mytown">
  <value>1.2343</value>
</mydata>
<mydata name="1" town="yourtown">
  <value>1.2349</value>
</mydata>
<mydata name="2" town="mytown">
  <value>2.2343</value>
</mydata>
What I want is to loop on town where name=2. I hope this helps. Thanks.
 
Old October 26th, 2007, 09:53 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I depends greatly on what kind of output you are trying to generate. If you're just wanting to filter then perhaps a <xsl:template match="mydata[@name=2]"> would do, or you might want to use the <xsl:for-each select="mydata[@name=2]"> element. Who knows...

/- Sam Judson : Wrox Technical Editor -/
 
Old October 30th, 2007, 01:24 PM
Registered User
 
Join Date: Apr 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, the for each did the trick.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace an attribute with another attribute georgemeng XSLT 8 June 10th, 2008 11:04 AM
Looping ssaranam SQL Server 2005 2 April 17th, 2008 01:40 AM
looping mrjoka Classic ASP Basics 1 September 26th, 2007 12:21 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
Looping..? dedex C# 2 January 6th, 2005 11:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.