DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);//开启命名空间
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(result.toString())));//用xml串构造源
System.out.println(getAsipReturnString(doc));
private Node getSoapBody(Document doc) {
NodeList bodyNodeList = doc.getElementsByTagNameNS(SOAP_NS, "Body");
int bodyNodeListLength = bodyNodeList.getLength();
Node body = null;
// 找到body
if (bodyNodeListLength > 0) {
body = bodyNodeList.item(0);
}
return body;
}
private String getAsipReturnString(Document doc) {
String asipReturnString = null;
NodeList asipResponseNodeList = doc.getElementsByTagNameNS(ASIP_NS, "callResponse");
int asipResponseNodeListLength = asipResponseNodeList.getLength();
Node asipResponse = null;
if (asipResponseNodeListLength > 0) {
// 找到callResponse节点
asipResponse = asipResponseNodeList.item(0);
if (asipResponse != null) {
// 找到callReturn节点
Node asipCallReturn = asipResponse.getFirstChild();
asipReturnString = asipCallReturn.getTextContent();
}
}
return asipReturnString;
}
分享到:
相关推荐
XML有3中解析方式:Jaxp、Jdom和dom4j 这个是sun公司提供的简单的Jaxp解析方式。
基于AjaxP的通用查询. 学习ajax的好资料
计算机科学与技术专业使用JAXP之SAX读取XML内容~~
使用SAX的优势在于其解析速度较快,相对于DOM而言占用内存较少。这篇文章主要介绍了Java中使用jaxp进行sax解析,需要的朋友可以参考下
JAXP 专述JAXP 专述JAXP 专述
day02_xml *demo01.App1\App2\App3 使用jaxp开发包中的SAX方式解析xml文档,该方式只能读取文档 *demo4j01.App dom4j CURD XML *domo4j.ex 对dom4j 的封装例子
超全面javaweb第4天-_22_使用jaxp查询节点
主要介绍了使用jaxp进行dom解析的相关资料,需要的朋友可以参考下
jaxp-api.jar sax.jar dom.jar xercesImpl.jar
超全面javaweb第4天-_24_使用jaxp查添加节点
解析JAXP
超全面javaweb第4天-_23_使用jaxp查询某一个节点
JAXP数据验证引擎 Serene源码示例
JAXP是JAVA API for XML Processing的缩写。本教程属于清晰版
基于java的开发源码-JAXP数据验证引擎 Serene.zip 基于java的开发源码-JAXP数据验证引擎 Serene.zip 基于java的开发源码-JAXP数据验证引擎 Serene.zip 基于java的开发源码-JAXP数据验证引擎 Serene.zip 基于java的...
JAXP数据验证引擎 Serene
供学习java xml参考
DOM(JAXP Crimson解析器) DOM是用与平台和语言无关的方式表示XML文档的官方W3C标准。DOM是以 层次结构组织的节点或信息片断的集合。
用Java解析XML文档,最常用的有两种方法:使用基于事件的XML简单API(Simple API for XML)称为SAX和基于树和节点的文档对象模型(Document Object Module)称为DOM。Sun公司提供了Java API for XML Parsing(JAXP)...
Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United Kingdom; by IDG Norge Books for Norway; by IDG Sweden Books for Sweden; by IDG Books ...