You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by St...@r2isante.fr on 2000/12/28 17:54:15 UTC
Réf. : How to Find and Return Specific Nodes
Hello,
I'm not a specialist of DOM (i'm more a newbie like you) but i'll give you
my opinion for your questions.
"Jean-Charles DUFOUR" <jc...@ifrance.com> le 28/12/2000 17:03:30
Veuillez répondre à xerces-j-dev@xml.apache.org
Pour : <xe...@xml.apache.org>
cc :
Objet : How to Find and Return Specific Nodes
> Hello,
> I've a newbie questions and I need some help.
> 1. How to find and return a NodeList containing all nodes nested in a
node
> (not only the childrens) and which have a specific tagName ?
> example :
> <NodeA>
> <NodeB/>
> <NodeB/>
> <NodeC>
> <NodeB/>
> </NodeC>
> <NodeA>
> If I scan the NodeA, I want to have in a NodeList all NodeB
Interface Element : Methods getElementsByTagName or getElementsByTagNameNS if you're using namespaces.
> 2. How to find and return a NodeListe containing childsNode of a node and
> wich have a specific tagName ?
> With the same example I want to have in a NodeList only the first and the
> second NodeB (the childrens)
I don't think there is method to do this in one step. I would use
Node.getChildNodes() and then loop on the result to find node of type
Element_node with the right tag.
> 3. How to find and return a NodeList containing all Node of un document
wich
> have a specific tagName, a specific attribute Name and a specific value
of
> this attribute ?
The interface Document implements the methods getElementsByTagName or
getElementsByTagNameNS. Then you could explore the result to find the
node matching your criterias.
A++
Stéphane