Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fetch UNIQUE IDs from XML tree

Status
Not open for further replies.

archer2002

Programmer
Dec 5, 2002
6
UA
Hello, I have the XSLT question.
I have the XML like
<nodes>
<node id = &quot;1&quot;/>
<node id = &quot;1&quot;/>
<node id = &quot;1&quot;/>
<node id = &quot;2&quot;/>
<node id = &quot;2&quot;/>
<node id = &quot;2&quot;/>
<node id = &quot;3&quot;/>
<node id = &quot;3&quot;/>
<node id = &quot;3&quot;/>
</nodes>

I have XSLT for-each loop like:
<xsl:for-each select=&quot;/nodes/node&quot;>
<xsl:value-of select=&quot;@id&quot;/>
...
</xsl:for-each>
I have output:
1
1
1
2
2
2
3
3
3
But I want each node with unique @id to be passed ONLY ONCE!
I other words I wanna have th output like
1
2
3

Please, help....
Sincerely,
Arsen
 
yea this gets a bit sticky.


afaik, you will need to use grouping on the values. this requires a little knowledge of keys, which are a little too involved to describe here.

take a look at the xslt tag &quot;<xsl:key>&quot; on any dev page. I found this one for you but there are loads more.


hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top