Page 1 of 1

How to get elements of nods

Posted: Tue Sep 17, 2019 10:41 pm
by Brian_donovan
Hi, pleas help I am in the need of getting all values from a nod here is my xml code:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<book>
<title font="arial" Textsize="12">The big book</title>
<price>10.90</price>
<year>1985</year>
</book>
</items >
here is my XSLT code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<td><xsl:value-of select="items/book/."/></td>
</xsl:template>
right now I get this:
The big book
10.90
1985
but I whant this:
arial
12
The big book
10.90
1985
Pleas help! :oops:

Re: How to get elements of nods

Posted: Thu Sep 19, 2019 8:22 am
by Radu
Hi,

You probably need to separately match and output the attributes like:

Code: Select all

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <td>
            <xsl:value-of select="items/book/title/@font"/>
            <xsl:text>                
</xsl:text>
            <xsl:value-of select="items/book/title/@Textsize"/>
            <!-- This only outputs the text content -->
            <xsl:value-of select="items/book/."/>
        </td>
    </xsl:template>
</xsl:stylesheet>
Regards,
Radu