Castor XML
可以把类生产xml
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
/**
* @author liujy
*
*/
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Document document=DocumentHelper.createDocument();
Element root= document.addElement("DataObject");
root.addElement("error").addText("0").addAttribute("name", "sdf");
root.addAttribute("name", "123");
Element account=root.addElement("account");
account.addElement("visitorId").addText("123");
account.addElement("name").addText("用户姓名");
// 暂无金额
account.addElement("money").addText("100000000000");
System.out.println(document.asXML());
}
}
可以把类生产xml
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
/**
* @author liujy
*
*/
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Document document=DocumentHelper.createDocument();
Element root= document.addElement("DataObject");
root.addElement("error").addText("0").addAttribute("name", "sdf");
root.addAttribute("name", "123");
Element account=root.addElement("account");
account.addElement("visitorId").addText("123");
account.addElement("name").addText("用户姓名");
// 暂无金额
account.addElement("money").addText("100000000000");
System.out.println(document.asXML());
}
}