Iterating through XML Nodes

Hi,
I have an XML as follows:

- <ratings>
- <Criteria TeamID="5" Code="cLTC00001">
<RequiredInfo ReqInfo="Required Info Areas To Improve LTC 1.1" />
</Criteria>
- <Criteria TeamID="5" Code="cLTC00002">
<RequiredInfo ReqInfo="Required Information LTC 1.2" />
<RequiredInfo ReqInfo="Required Information LTC 1.2" />
</Criteria>


I have a <xsl:for-each> to loop through each criteria. And I display the Required Information for that corresponding criteria.

Problem comes when a criteria has 2 requiredinfo. I need to set up the counter and need to display the requiredinfo at position 2 when I loop through the counter. Can someone help me with the Syntax please.

The following is the XSL I currently have:

<xsl:for-each select="./RequiredInfo">   <!-- This comes from XML Doc 1-->
<tr>
<td>&#160;</td>
<td>&#160;</td>
<td valign="top" class="details">
<xsl:value-of select="@TextDetails" />
<br></br>
</td>
</tr>
<tr>
<td>&#160;</td>
<td>&#160;</td>
<xsl:if test="string-length(document($dataURL1)/*/Criteria[@Criteria = $criteria]/RequiredInfo) > 0">

<Comments>  for your understanding
<!-- DataURL1 is a reference to stored procedure like this <xsl:variable name="dataURL1">
            <!--<xsl:value-of select="'http://xyz/ams_sqlxml2?sql=select+*+from+vSACriteriaRatings+where+TeamID=7+for+xml+auto,Elements&root=ratings'" />-->
            <xsl:value-of select="'http://comet/ams_sqlxml2?sql=spCCHSA_RatingandReqInfoTree+5&root=ratings1'" />
      </xsl:variable> -->
<Comments>

<td>
<table style="border:1px black solid" cellpadding="5" class="nothing" width="100%">
<tbody>
<tr>
<td>
<xsl:value-of select="document($dataURL1)/*/Criteria[@Criteria = $criteria]/RequiredInfo" />
</td>
</tr>
</tbody>
</table>
</td>
</xsl:if>
</tr>
</xsl:for-each>

Thanks
Vijaya
CCHSAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StiowCommented:
Just to clarify - what you want to do is display the LAST one if there are more than one?  If there were 10 would you still want to display number 2, or would you want to display number 10?

Stuart.
0
CCHSAAuthor Commented:
Thanks Stuart,

I resolved this thing. When I removed the TeamID in the XML and have only the criteria in the child node, it worked.
0
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.