java之读取xml字符串

来源:互联网 发布:听书软件平果版 编辑:程序博客网 时间:2024/06/06 04:17
Document document = null;
try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
// 接收航信电子票返回的信息
document = builder.parse(new ByteArrayInputStream(retStr
.getBytes("utf-8")));
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("开票失败!!!解析航信返回信息为: " + document);
}
NodeList fphm = document.getElementsByTagName("FP_HM"); // 发票号码

NodeList fpdm = document.getElementsByTagName("FP_DM"); // 发票代码


import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

0 0
原创粉丝点击