• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

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
0
CCHSA
Asked:
CCHSA
1 Solution
 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now