Convert Xml List To Html Table Using Xsl
Hello I was struggling with this for the past days and I could not find a good answer nor solution. I have an XML file with a list of objects like this:
Solution 1:
lineitmes folllow a regular pattern.
Then I believe it could be simply:
XSLT 1.0
<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:outputmethod="html"encoding="UTF-8"/><xsl:strip-spaceelements="*"/><xsl:templatematch="/LineItems"><xsl:variablename="columns"select="count(ColumnMetadata)"/><tableborder="1"><thead ><tr><xsl:for-eachselect="ColumnMetadata"><th><xsl:value-ofselect="Term"/></th></xsl:for-each></tr></thead><tbody><xsl:for-eachselect="LineItems[position() mod $columns = 1]"><tr><xsl:for-eachselect=". | following-sibling::LineItems[position() < $columns]"><td><xsl:value-ofselect="*"/></td></xsl:for-each></tr></xsl:for-each></tbody></table></xsl:template></xsl:stylesheet>
Post a Comment for "Convert Xml List To Html Table Using Xsl"