Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Iterating through XML Nodes

Posted on 2004-10-27
4
Medium Priority
?
162 Views
Last Modified: 2010-04-17
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
Comment
Question by:CCHSA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:Stiow
ID: 12433644
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
 

Author Comment

by:CCHSA
ID: 12437029
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12654112
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question