This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Unable to create child elements.... XMl Parsing... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unable to create child elements.... XMl Parsing..." Watch "Unable to create child elements.... XMl Parsing..." New topic
Author

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

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 761
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 :



Jigar Naik


Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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

Joined: Dec 12, 2006
Posts: 761
ya i did that and its working fine...



Thanks....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to create child elements.... XMl Parsing...
 
It's not a secret anymore!