Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add child using JDOM

843834Aug 27 2001 — edited Aug 28 2001
I am trying write a program to write an xml file in a servlet. I started to write the code but when I try to add a child to an element I get an error. Here is a sample of my code:

Namespace ns = Namespace.getNamespace("TestXML", nameSpace);
Element root = new Element("Book", ns);
Document doc = new Document(root);
Element child1 = new Element("Child", ns);
root.addChild(child1);

But when I compile this code I get the following error:

cannot resolve symbol
symbol: method addChild (org.jdom.Element)
location: class org.jdom.Element
root.addChild(child1);

Is this the proper way to add a child to an element using JDOM. I just downloaded the .jar file last week so I don't think this is a version problem.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2001
Added on Aug 27 2001
2 comments
672 views