RE: [xsl] Can I access the children by their Index?

Subject: RE: [xsl] Can I access the children by their Index?
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Tue, 27 Feb 2001 16:20:11 -0000
You are looking at this the wrong way
Beginners rule #1 *NEVER* use for-each
I guess you want to make a table with rows for each of the children of
What you want is something like this
<xsl:template match="ESTIMATEDATA">
		<xsl:apply-templates />
<xsl:template match="ESTIMATEDATA/*">
		<td><xsl:value-of select="@name" /></td>
		<td><xsl:value-of select="@grade" /></td>
		<td><xsl:value-of select="." /></td>

But then maybe you don't.

Ciao Chris

XML/XSL Portal

>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Daniel Newman
>Sent: 27 February 2001 15:34
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: RE: [xsl] Can I access the children by their Index?
>sorry all, thought my original request might confuse. Time for more
>illustration. My XML (the part we're interested in anyway) looks like this:
>  <SALES name="Sales" grade="none">***.*</SALES>
>  <PROFIT name="Profit" grade="none">**.*</PROFIT>
>  <EPS name="EPS" grade="none">**.*</EPS>
>  <CFPS name="CFPS" grade="none" />
>  <DPS name="DPS" grade="none">**.**</DPS>
>  <PE name="P/E Ratio" grade="none">**.*</PE>
>  <DIVCOVER name="Div Cover" grade="none">*.*</DIVCOVER>
>  <DIVYIELD name="Yield" grade="none">*.*</DIVYIELD>
>  <PEG name="PEG Factor" grade="none" />
>Now I want to set up a function that will loop 9 times, and then retrieve
>the value of that child node. I don't want to refer to each child by their
>name, as this would mean getting rid of the loop and having nine
>table rows.
>There must be a way of accessing CFPS without calling it by name. So again,
>can I get the value of CFPS by doing something like:
>xsl:value-of select="../../../ESTIMATEDATE/child(4)/@name"
>Anyone had this problem?
>Thanks if you know
> XSL-List info and archive:

 XSL-List info and archive:

Current Thread