File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How to create Elements and Attributes using ElementImpl Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "How to create Elements and Attributes using ElementImpl" Watch "How to create Elements and Attributes using ElementImpl" New topic
Author

How to create Elements and Attributes using ElementImpl

Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Hi,
I have a basic XML template.I read this template and want to add elements to it.
Here is what I did...
Document xmlDoc = parser.parse("Tree.xml");
Element ele = xmlDoc.createElement("Element1");
ele.setAttributes("Attribute1", "Value1");
.....
It is not throwing any exception, but if I traverse the nodes I can't see the elements and attributes that I have added.
I greatly appreciate any help.
Thanks.
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
You created the Element, yes, but you forgot to add it to your document. Add an element to any Node by calling appendChild( Node) and pass the element that you wish to add as the argument.
SAF
Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
SAF,
Thanks...I just found out this.
Thanks for your reply...
-shoba
 
 
subject: How to create Elements and Attributes using ElementImpl
 
Threads others viewed
Thread safe
Could you transform xml into a diff't xml
XML design question
How do i know what are the elements ,subments ,attributes in a xml file ?
Significance of this tag
MyEclipse, The Clear Choice