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 May 25th, 2006, 10:24 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Element loop

Hi,

I want to loop through every occurence of an element which appears in a multi-lined XML sheet. Within each element there are attributes and child elements. How do I loop/read or 'For Each' through these?

Code:
<Document Name="LABSAMPLE">
<Test Code="0001">
    <Set No="1">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
    <Set No="2">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
</Test>
<Test Code="0004">        
    <Set No="1">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
    <Set No="2">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
</Test>
<Test Code="0017">
    <Set No="1">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
    <Set No="2">
        <Targ>12.40</Targ>
        <Min>10.90</Min>
        <Max>13.90</Max>
    </Set>
</Test>
</Document>
Can anyone help please?

Thanks in advance,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old May 25th, 2006, 11:06 AM
Authorized User
 
Join Date: May 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to boen_robot
Default

I'm not sure I get you. Looping through items is done with
Code:
<xsl:for-each select="XPath expression or function">

</xsl:for-each>
And I bet you know it (isn't that one of the first things in XSLT tutorials?), but what exactly you need to match? All elements and attributes? Then the XPath expression would be something like
Code:
//*|//@*
------
<xsl:for-each select="problem"><xsl:value-of select="solution"></xsl:for-each>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
translate element name to element name lexzeus XSLT 3 September 4th, 2006 09:04 AM
Getting form element names in a loop crapanz Javascript 5 January 30th, 2006 12:45 AM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





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