This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Getting only the immediate child elements in DOM parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Getting only the immediate child elements in DOM parsing" Watch "Getting only the immediate child elements in DOM parsing" New topic
Author

Getting only the immediate child elements in DOM parsing

Vinayak patil
Ranch Hand

Joined: Aug 30, 2005
Posts: 67
Hi,

I am using DOM parsing to parse an XML .

I using the following code:



This would return all the elements having the tagName specified going down to all the children of the element el.
I would like to get only the immediate child elements of el having the tagName specified.
Is there a way to do in DOM parsing?

I cannot change it to SAX parsing since the above code is a part of a pretty large project.

- Vinayak


"I can resist everything except temptation"
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
For each Node in the NodeList you could use getParentNode() and compare it to Element e1.

Bill
Vinayak patil
Ranch Hand

Joined: Aug 30, 2005
Posts: 67
Thanks !! . It works.


- Vinayak
 
jQuery in Action, 2nd edition
 
subject: Getting only the immediate child elements in DOM parsing
 
Similar Threads
Dom parser for XML file
Element with same name
Efficient XML Parsing
Double xml read
Document getChildren with TagName