欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java xml转map

程序员文章站 2022-05-19 15:33:32
...
String responseText = (String) resultMap.get("responseText");
				  responseText=HttpUtil.dealWithGash(responseText);
				resultData = HttpUtil.getYbMap(responseText);
				public static Map getYbMap(String xmlString) throws Exception {

		Map returnmap=new HashMap();
		Document doc = null;
		doc = DocumentHelper.parseText(xmlString);
		Element businessdata = (Element) doc.selectSingleNode("//businessdata");
		for (Iterator iterator = businessdata.elementIterator(); iterator.hasNext();) {
			 Element e = (Element) iterator.next();
			 returnmap.put(e.getName(), e.getText());
		  }



		return returnmap;
	}