I have the following XML code:
and am using the following XSLT code:
in coordination with the W3 Schools "Tryit Editor" tool for XSLT. I can't link it due to reputation.
My problem is that the XSLT does not parse all the elements (semester elements within a catalog element, and class elements within a semester element).
The W3 schools example of XSLT uses only one subelement, and I'm at a loss for what to do for two subelements.
My understanding is that the first
<xsl:for-each select="catalog/semester">
will loop semester elements in the catalog elements.
Within the loop, I have a HTML table where I want to output the information of the class element, that is a subelement of semester. I think nesting this code in the original for-each loop should output the text for each element for each class in the table:
<xsl:for-each select="class">
<td><xsl:value-of select="dept"/></td>
<td><xsl:value-of select="number"/></td>
<td><xsl:value-of select="title"/></td>
</xsl:for-each>
In the HTML table, only the text, "CIT", of the first subelement, dept, of the element class is displayed.
I deduct that the for-each loop isn't parsing. If that is the reason, why?
If my deduction on why the XSLT code isn't reading the XML code how I want it is incorrect, what is the correct reason and how can I fix it?