Extract a specific attribute from an element using XSLT

Q

Using XSLT, how would you extract a specific attribute from an element in an XML document?

✍: FYICENTER.com

A

Successful candidates should recognize this as one of the most basic applications of XSLT. If they are not able to construct a reply similar to the example below, they should at least be able to identify the components necessary for this operation: xsl:template to match the appropriate XML element, xsl:value-of to select the attribute value, and the optional xsl:apply-templates to continue processing the document.

XSLT Exapmple of extract Attributes from XML Data:

<xsl:template match="element-name">
Attribute Value = <xsl:value-of select="@attribute"/>
<xsl:apply-templates/>
</xsl:template>

2007-04-11, 4879👍, 0💬