- From: Nigel Byrnes <byrnes@prl.research.philips.com>
- Date: Thu, 08 Apr 1999 22:33:21 +0100
- To: www-dom@w3.org
- Message-Id: <370D20A1.A1DAFF46@prl.research.philips.com>
Hi all I have a requirement to find out how many times an Element of a particular name occurs in a subtree of document below a Node n. The approach which I believe I should take is: - create a subtree whose root is at n - employ the getElementsByTagName(name) method to generate an appropriate NodeList To create subtrees, there is the DocumentFragment interface. And here is my problem: I don't know how to use any of the methods to create a documentFragment beneath a given Node (I'm not a programming vet', you see). Is this the correct approach to take? The alternative I see is a little more complex: - determine all the child Nodes of Node n, by applying the getChildNodes() method in breadth-first manner on all element nodes at and beneath n. - manually pick out those nodes with a particular nodeName. I believe the Element interface approach to be the more elegant...Any advice on how I can realise it would be cool. Regards Nigel PS Just trawled through the archives and couldn't find the answer...:-(
Received on Thursday, 8 April 1999 17:36:19 UTC