You could use it like sample :
<?xml version="1.0" encoding="UTF-8"?>
<car vin="123fhg5869705iop90">
<!--Description of a car-->
<make>Toyota</make>
<model>Celica</model>
<year>1997</year>
<color>green</color>
<license state="CA">1ABC234</license>
</car>
Element carElement = new Element("car");
Document myDocument = new Document(carElement);
carElement.addAttribute(new Attribute("vin", "123fhg5869705iop90"));
Element make = new Element("make");
make.addContent("Toyota");
carElement.addContent(make);
carElement.addContent(new Element("make").addContent("Toyota"));
carElement.addContent(new
Element("model").addContent("Celica"));
carElement.addContent(new Element("year").addContent("1997"));
carElement.addContent(new Element("color").addContent("green"));
carElement.addContent(new Element("license")
.addContent("1ABC234").addAttribute("state", "CA"));
But if you wanna use the best practice of xml parsing you could use
Stax Parser that it contains Cursor API and Iterator API and simply
programming.