Add child using JDOM
843834Aug 27 2001 — edited Aug 28 2001I 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.