50,857
社区成员
发帖
与我相关
我的任务
分享
String respXmlData = "<RespInfo><ResultStatus>02</ResultStatus><ResultCode>BD1003</ResultCode></RespInfo>";
try {
Document document = DocumentHelper.parseText(respXmlData);
System.out.println(document.asXML().toString());
// 获取节点元素对象与值
Element rootNode = document.getRootElement();
Element respInfoNode = rootNode.element("RespInfo");
System.out.println(respInfoNode.getText());
} catch (DocumentException e) {
e.printStackTrace();
}
String respXmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><Document><RespInfo><ResultStatus>02</ResultStatus><ResultCode>BD1003</ResultCode></RespInfo></Document>";
try {
Document document = DocumentHelper.parseText(respXmlData);
System.out.println(document.asXML().toString());
// 获取节点元素对象与值
Element rootNode = document.getRootElement();
System.out.println("根节点名称是:" + rootNode.getName());
Element respInfoNode = rootNode.element("RespInfo");
System.out.println(respInfoNode.element("ResultStatus").getText());
} catch (DocumentException e) {
e.printStackTrace();
}
Document document = DocumentHelper.parseText(respXmlData);
System.out.println(document.asXML().toString());
// 获取节点元素对象与值
Element rootNode = document.getRootElement();
Element resultStatus = rootNode.element("ResultStatus");
Element resultCode = rootNode.element("ResultCode");
System.out.println(resultStatus.getText());
System.out.println(resultCode.getText());