This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: how to get the value ?
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: how to get the value ?
- From: Heather Lindsay <heather dot lindsay at Trifolium dot com>
- Date: Wed, 31 May 2000 10:36:20 -0400
- Reply-To: xsl-list at mulberrytech dot com
" xml structure
<?xml version="1.0"?>
<first>
<second> data1
<child att="x">data2</child>
</second>
</first>
I want to fetch the values "data1" and "data2" ."
The above is not well-formed XML because elements with child elements cannot
also have a text element. You could either have another child element with
"data1" in it or set "data1" as the value of an attribute in your "second"
element (<second attrib=data1>). For learning XSLT, I strongly recommend
THE book, "XSLT Programmer's Reference" by Mike Kay (published by Wrox).
You will probably need to order the book online as it is still very new and
not yet in very many book stores.
If your XML doc. was as follows:
<first>
<second>
<child1> data1 </child1>
<child2 att="x">data2</child2>
</second>
</first>
Then the following XSL would get the values you want:
<xsl:stylesheet .............>
<xsl:template match="/">
<HTML>
<BODY>
<p><xsl:value-of select="second/child1"/></p>
<p><xsl:value-of select="second/child2"/></p>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Producing the following HTML:
<HTML>
<BODY>
<p> data1 </p>
<p> data2 </p>
</BODY>
</HTML>
Good luck,
Heather
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list