1、Java生成XML
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
Document document = DocumentHelper.createDocument();
Element rootElement = document.addElement("root节点");
Element element = rootElement.addElement("节点名1");
Element fidNode = element.addElement("节点名2");
fidNode.addAttribute("节点名2的属性名", “属性值”);
Element fnameNode = element.addElement("节点名1-1");
fnameNode.addAttribute("节点名1-1属性名", “属性值”);
return rootElement.asXML(); //转成XML字符串返回
2、Java解释XML
Document document = DocumentHelper.parseText(resultString); //解释XML字符串
Element rootElement = document.getRootElement();
Element isloginElement = rootElement.element("节点名称");
String aaString=isloginElement.getText(); //获取节点的Text值