/*   * @Program to read an XML document using JDOM?  * ReadingxmlusingJdom.java   * Author:-RoseIndia Team  * Date:-10-Jun-2008  */ import org.jdom.Document; import org.jdom.Element; import org.jdom.input.SAXBuilder; import java.io.ByteArrayInputStream; import java.util.List; public class ReadingxmlusingJdom {     public static void main(String[] args) throws Exception {         String data =                 "" +                 "" +                 "Developer" +                 "" +                 "" +                 "Administrator" +                 "" +                 "";         SAXBuilder builder = new SAXBuilder();         Document document = builder.build(new ByteArrayInputStream(data.getBytes()));         Element root = document.getRootElement();             List row = root.getChildren("Companyname");         for (int i = 0; i < row.size(); i++) {             Element Companyname = (Element) row.get(i);                         List column = Companyname.getChildren("Employee");             for (int j = 0; j < column.size(); j++) {                 Element Employee = (Element) column.get(j);                 String name = Employee.getAttribute("name").getValue();                 String value = Employee.getText();                 int length = Employee.getAttribute("Age").getIntValue();                 System.out.println("Name = " + name);                 System.out.println("Profile = " + value);                 System.out.println("Age = " + length);             }         }     } }