1

I'm very new to XSLT and XML. I'm trying to make a dynamic list based on how many CASES come back from an XML file.

The XML section about CASES looks like this:

...
<CASES>
    <CASE>000000000000014-00001</CASE>
    <CASE>000000000000014-00002</CASE>
    <CASE>000000000000014-00003</CASE>
</CASES>
...

My XSLT code (excerpt) for the table I'm creating looks like this:

...
CASES:
<table style="width: 100%;">
<xsl:for-each select="CASES/CASE">
    <tr>
        <td><xsl:value-of select="CASE"/></td>
    </tr>
</xsl:for-each>
</table>
...

The output is three blank table rows. Could you please tell me what I'm doing wrong?

1 Answer 1

1

Since your xsl:for-each loop alread selects CASE elements,

<xsl:for-each select="CASES/CASE">

your xsl:value-of shouldn't be

    <td><xsl:value-of select="CASE"/></td>

because that looks for a CASE child of the current CASE element.

Instead, within the loop just select the current element itself, available as .:

    <td><xsl:value-of select="."/></td>
Sign up to request clarification or add additional context in comments.

2 Comments

It worked. Thank you. It put them side by side. Any advice on how I can get them each in their own row?
Your shown XSLT snippet already has them in their own row by virtue of the <tr>...</tr> that wraps the single td elements within the CASE loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.