This will give you quickbrownfox.
Let me know if I have misunderstood your question.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/xml">
<xsl:value-of select="CCC/DDD[(_at_)attrib='123'][1]"/>
<xsl:value-of select="CCC/DDD[(_at_)attrib='456'][1]"/>
<xsl:value-of select="CCC/DDD[(_at_)attrib='456'][2]"/>
</xsl:template>
</xsl:stylesheet>
-----Original Message-----
From: Manuel Reyes [mailto:Manuel(_dot_)Reyes(_at_)e-mis(_dot_)com]
Sent: Thursday, April 29, 2004 9:11 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Using XPath to retrieve nodes by attribute.
Hello all,
I have the following XML document:
<xml>
<AAA>foo</AAA>
<BBB>bar</BBB>
<CCC>
<DDD attrib="123">quick</DDD>
<DDD attrib="456">brown</DDD>
<DDD attrib="789">fox</DDD>
<DDD attrib="123">jumped</DDD>
<DDD attrib="456">lazy</DDD>
<DDD attrib="789">dog</DDD>
</CCC>
</xml>
If I run the following XPath query it returns the count of all nodes in
CCC that have an attrib value of "123":
xml/CCC/DDD[(_at_)attrib='123'] = 2
What I am trying to do now is retrieve a particular node based on the
position in the CCC node and its attribute, something like this:
xml/CCC/DDD[(_at_)attrib='123'][1] = quick
xml/CCC/DDD[(_at_)attrib='456'][1] = brown
xml/CCC/DDD[(_at_)attrib='456'][2] = lazy
This is based on information I found here:
http://www.w3schools.com/xpath/xpath_location.asp
Unfortunately this does work, can anybody tell me where I am going wrong
Thanks
Manuel
--+------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--