Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to create child elements.... XMl Parsing...

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folloing is the structure of my XML file

XML file : bofore adding child node to root node.



Method to add child node to a parent node



ERROR I'm getting :

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getElementsByTagName returns a NodeList, not an Element. I'm curious how that code can even compile.

If you're certain that the list only contains a single element, then something like

Element element = (Element) doc.getElementsByTagName("blog").item(0);
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i did that and its working fine...



Thanks....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic