Help Nodes Contains function not working ???

G

Guest

Dear all,

I am populating a treeview control with an XML file.
I need to skip duplicate node entry from XML file in treeview if exit

For that I ma using the following line of code :

If NodeCollection.Contains(node) Then Return True

That function always return false.
If I go through nodeCollection object and check if my Node object exist I
can saee it already in the collection.

Why the Contains return always false ?
Waht is the criteria that identify an existing node iunn the collection, is
it ist name?

Thnaks for helping me how to identify an exiting node
regards
serge
 
F

Felipe

Hi Serge

If you are using the XML DOM... I believe that every XmlNode is a different
Object.... therefore two different nodes of the same type(or even identical)
will never match because they are different objects. I might be wrong
though!! so don't hold me back on it!!!

So... what I have done in my codes, to find similar nodes is to take a
target node to check for a duplicate....take a XmlNodeList of nodes to check
against... and compare their attributes...see if they have same number of
attributes.... if they have the same attribute names and values( remember
that attributes order might not match, alltought they are identical ).
That would do it if the nodes have no children.... but if they do.... that's
a whole other can of worms....
 
G

Guest

Hi Felipe,

OUps I am lost now.
ket me explain again, first here is below a sample of my XML node :
======================================
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<REC_INFO>
<FILE_NAME>REC00001.CSV</FILE_NAME>
<Type>Pipe</Type>
<RECIPE_NAME>25 x 2.5 mm</RECIPE_NAME>
<LINE_NAME>LP602</LINE_NAME>
<GROUPE_NAME>LP602</GROUPE_NAME>
<MODIFIED>02.11.2004 15:15</MODIFIED>
</REC_INFO>
<REC_INFO>
=========================================

I van have many of those and I am building a treeview nodes only from the
xml node named <Type>. What you see above, I can get more, on the same file
with the same node name but different value.

For the <TYpe> node, If this node value has been already added previously in
my trreenode colection then I should skip it.

And this is what I ma try ing to do with the Contains function

Any other ideas how to do that?

thnaks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top