---
title: "Using XSLT, how would you extract a specific attribute from an element in an XML document?"  
description: "Using XSLT, how would you extract a specific attribute from an element in an XML document?"  
author: "Dependra Pathak"  
published: 2011-03-18  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/507/using-xslt-how-would-you-extract-a-specific-attribute-from-an-element-in-an-xml-document  
category: "xml"  
tags: ["xml"]  
reading_time: 1 minute  

---

# Using XSLT, how would you extract a specific attribute from an element in an XML document?

**Extract Attributes from XML Data** \
**Example:**\
<xsl:template match=”element-name”>\
Attribute Value:\
<xsl:value-of select=”@attribute”/>\
<xsl:apply-templates/>

</xsl:template>

Note: 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.

## Answers

### Answer by Dependra Pathak

**Extract Attributes from XML Data** \
**Example:**\
<xsl:template match=”element-name”>\
Attribute Value:\
<xsl:value-of select=”@attribute”/>\
<xsl:apply-templates/>

</xsl:template>

Note: 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.


---

Original Source: https://www.mindstick.com/interview/507/using-xslt-how-would-you-extract-a-specific-attribute-from-an-element-in-an-xml-document

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
