把一个xml节点信息递归的存到map中的方法
jar包自己加!!
import java.util.HashMap;import java.util.Iterator;import java.util.Map;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.DocumentHelper;import org.dom4j.Element;public class XmlUtil {public static Map<String, Object> doInfoXML(String infoXML) {Document document;Map<String, Object> map = new HashMap<String, Object>();try {document = DocumentHelper.parseText(infoXML);Element root = document.getRootElement();Iterator it = root.elements().iterator();while (it.hasNext()) {Element info = (Element) it.next();map.put(info.getName(), info.getText());Iterator itc = info.elements().iterator();while (itc.hasNext()) {Element infoc = (Element) itc.next();map.put(infoc.getName(), infoc.getText());}}} catch (DocumentException e1) {e1.printStackTrace();}return map;}}