Iterating through attributes using xslt
11,017
You can use this XPath @*
to get all attributes, e.g.:
XML:
<Roll NO="4620" CLASSNO="0" ID="0" DID="0" REVSN="0" DNO="3"/>
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/*">
<xsl:for-each select="@*">
<xsl:value-of select="concat(name(), ': ', ., ' ')"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output:
NO: 4620 CLASSNO: 0 ID: 0 DID: 0 REVSN: 0 DNO: 3
Author by
Tom Cruise
Updated on June 07, 2022Comments
-
Tom Cruise almost 2 years
I have an xml data which has shown below.
<Roll NO="4620" CLASSNO="0" ID="0" DID="0" REVSN="0" DNO="3" ></Roll> <Roll NO="4630" CLASSNO="0" ID="0" DID="0" REVSN="0" DNO="3"></Roll>
I want to iterate through the attributes without specifying the name using XSLT. Any way to do it?