Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting only the immediate child elements in DOM parsing

 
Vinayak patil
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For each Node in the NodeList you could use getParentNode() and compare it to Element e1.

Bill
 
Vinayak patil
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks !! . It works.


- Vinayak
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic