How to get elements of nods

Questions about XML that are not covered by the other forums should go here.
Brian_donovan
Posts: 3
Joined: Tue Sep 17, 2019 10:27 pm

How to get elements of nods

Post by Brian_donovan » Tue Sep 17, 2019 10:41 pm

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:

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to get elements of nods

Post by Radu » Thu Sep 19, 2019 8:22 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply