Hello Arnaud!!

I will use the second option.

thanks for your help!!




-----Original Message-----
From: Arnaud Le Hors [mailto:[EMAIL PROTECTED]
Sent: lunes, 12 de febrero de 2001 17:49
To: [EMAIL PROTECTED]
Subject: Re: Problem calling getElementsByTagName in depth


Short answer: no. You're going to have to do some filtering yourself.

Longer answer: I don't know exactly what your criteria to select some B
elements and not the other. But in any case all it means is that as you
go through the list you need to test and see if the node actually pass
the test that suites you before proceeding.
For instance, if your test is "must be child of A" you can simply do
something like:

NodeList nodes = getElementsByTagName("B", nodeA);
for (int i = 0; i < nodes.getLength(); i++) {
   Node nodeB = nodes.item(i);
   if (nodeB.getParentNode() != nodeA)
       continue;
   ...
}

But actually if all you're looking for is the direct children of A this
is overkilling. You'd better walk through the list of the node's
children. It will be much more efficient:

NodeList nodes = nodeA.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
   Node child = nodes.item(i);
   if (!child.getNodeName().equals("B"))
       continue;
   ...
}
-- 
Arnaud  Le Hors - IBM Cupertino, XML Strategy Group

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

This message and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
No confidentiality or privilege is waived or lost by any wrong transmission.
If you have received this message in error, please immediately destroy it
and kindly notify the sender by reply email.
You must not, directly or indirectly, use, disclose, distribute, print, or
copy any part of this message if you are not the intended recipient.
Opinions, conclusions and other information in this message that do not
relate to the official business of Newknow shall be understood as neither
given nor endorsed by it. 

Reply via email to