Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you access an element by its attribute value using XSL transforms and XML?

Tags:

xml

xhtml

xslt

Im trying to transform an XML document into XHTML using XSL transformation and was wondering how i can choose an XML element given the value of its attribute. e.g.

<image size="small">http:example.small.jpg</image>
<image size="medium">http:example.medium.jpg</image>
<image size="large">http:example.largw.jpg</image>

I only want to access the value "http:example.medium.jpg" from the image tag where size="medium".

Any help is greatly appreciated.

Ally

like image 390
allyLogan Avatar asked Dec 03 '09 17:12

allyLogan


People also ask

What attribute is used with the xsl if element?

<xsl:if> Example<? xml version="1.0"?>

Which of the following xsl:element is used to extract information from XML?

XSLT <xsl:value-of> Element.

How does XSLT transform XML?

The standard way to transform XML data into other formats is by Extensible Stylesheet Language Transformations (XSLT). You can use the built-in XSLTRANSFORM function to convert XML documents into HTML, plain text, or different XML schemas. XSLT uses stylesheets to convert XML into other data formats.


1 Answers

<xsl:value-of select="image[@size='medium']" />
like image 128
carillonator Avatar answered Oct 07 '22 16:10

carillonator