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!

Is it possible to use a distinct like statement?

Status
Not open for further replies.

Fursten

Programmer
Dec 27, 2000
403
PT
Hi,

Anyone knows if its possible to do suchthing like choose a collection of elements from a XML tree, and depending of the value of an attribute of those elements, get only one element per attribute.

For exemple, if I have this:

<table id=2>
</table>
<table id=3>
</table>
<table id=2>
</table>

I would like to get a colleccion of table elements like this:

<table id=2>
</table>
<table id=3>
</table>

So, I don´t need another table element because the ID is the same. In other words, I would like to make a distinct in my XPath... to obtain an element table per ID.

Something like: getElementsByTagName(&quot;//table/distinct ID&quot;)

Is this possible?

Thank you,

Sergio Oliveira
 
Hello,
Try selectNodes method. It will return a collection of nodes, and you could use RemoveChild method do remove unnecessary node.
Or keep track of your id-s in a loop and use method selectSingleNode which will return first match.
Then you have to construct collection of nodes by yourself.

Hope this helps.
D.
 
You must be able to use XSL:Key somehow. If I get chance over the weekend, I'll have a look.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top