| Author |
DOM Parsing
|
Gaurav Chikara
Ranch Hand
Joined: Jun 09, 2000
Posts: 410
|
|
Hi Is there any way using DOM API to find out how many occurences of a particular Node name are there in our XML As I m trying to find a node having multiple occurences but when i try to find it it stops after giving value of first node only
|
SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
|
 |
chris leonardi
Greenhorn
Joined: Feb 25, 2001
Posts: 3
|
|
Hi Gaurav - This may not be the most elegant approach, but it should work: Element root = doc.getDocumentElement(); NodeList nodes = root.getElementsByTagName("match"); int count = nodes.getLength(); One thing to keep in mind with this tactic is that it will match all matching descendents of the current element. For instance: <a1> <b1><match /></b1> <b2><match /></b2> <b3><match /></b3> <b4> <c1><match /></c2> <c2><match /></c2> <c3> <d1><match /></d1> <d2><match /></d2> </c3> </b4> </a1> This would find 7 nodes. Hope that helps. Chris
|
 |
 |
|
|
subject: DOM Parsing
|
|
|