JDOM-Modify xml or add new elements to XML

 The JDOM api is used for modifying the xml and adding new Element and values to the existing xml.
/*
 * add jdom2.2 jaR TO CLASSPATH FOR THE PROGRAM TO WORK*/
jaxen, xercesImpl.jar,xml-apis.jar

Download the source code from the below link.
The Jar file contains a main program, which demonstates how to use the JDOM api.
All we have to do is modify the main program-with your file name
and provide the parameters.
Add the other source file to the class path.Or add the jar to the class path with above mentioned JAR-Jdom and xml related jar

https://docs.google.com/open?id=0Bw0JiVGLs_kUckZmSWt4NGpFNms

package com.anjana.xmlutils;

import java.io.File;

public class ModifyMain {
    public static void main(String args[]){
        File xmlFile = new File("c:\\myfile.xml");
        ModifyXMLFileClient modifyclient=new ModifyXMLFileClient(xmlFile);
        modifyclient.modify_xmlattribute("staff","id","3");
        modifyclient.add_xmlelement("staff","location","bangalore");
        modifyclient.modify_xmlelement("staff","salary","20000");
        modifyclient.delete_xmlelement("staff","age");
        modifyclient.delete_xmlelement("staff","location");
        System.out.println("File updated!");
    }
   
}

Comments

Popular posts from this blog

defining functions clojure

How to retain the space of the td after hidding it in Jquery

Integrating Struts2 with Spring Security using Custom Login Form