axiom解析xml

前端之家收集整理的这篇文章主要介绍了axiom解析xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

用axiom解析xml,axis2中常用

	public static Map<String,String> getResults(OMElement element) {
		if (element == null) {
			return null;
		}
		Iterator<OMNode> iter = element.getChildElements();
		Map<String,String> map = new HashMap<String,String>();
		while (iter.hasNext()) {
			OMNode omNode = (OMNode) iter.next();
			if (omNode.getType() == OMNode.ELEMENT_NODE) {
				OMElement omElement = (OMElement) omNode;
				String key = omElement.getLocalName().trim();
				System.out.println("键: " + key);
				String value = omElement.getText().trim();
				System.out.println("值: " + value);
				map.put(key,value);
			}
		}
		return map;
	}
转载 http://blog.csdn.net/mengxianhua/article/details/8024666 原文链接:https://www.f2er.com/xml/295343.html

猜你在找的XML相关文章