This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting only the immediate child elements in DOM parsing  RSS feed

 
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: 13078
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
Boost this thread!