Source Code : Simple example of using JDOM

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Simple example of using JDOM

  
import java.util.Iterator;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

/**
 * @author robh
 *  
 */
public class HelloPeopleJDOM {

    public static void main(String[] args) throws Exception {
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build("./src/data.xml");

        StringBuffer output = new StringBuffer();

        // create the basic HTML output
        output.append("<html>
").append(
                "<head>
<title>
Person List</title>
</head>
").append(
                "<body>
").append("<ul>
");

        Iterator itr = doc.getRootElement().getChildren().iterator();

        while (itr.hasNext()) {
            Element elem = (Element) itr.next();

            output.append("<li>");
            output.append(elem.getAttribute("lastName").getValue());
            output.append(", ");
            output.append(elem.getAttribute("firstName").getValue());
            output.append("</li>
");
        }

        // create the end of the HTML output
        output.append("</ul>
</body>
</html>");

        System.out.println(output.toString());
    }
}

           
         
    
  

Thank with us