将字符串转为XML Document doc = DocumentHelper.parseText(xml); // 将字符串转为XMLif(doc!=null){ doc.getRootElement().normalize(); String status1 = doc.selectSingleNode("return/status").getText(); //获取节点status的文本值
Document doc = DocumentHelper.parseText(xml); // 将字符串转为XML
if(doc!=null){
doc.getRootElement().normalize();
String status1 = doc.selectSingleNode("return/status").getText(); //获取节点status的文本值
String status2 = doc.selectSingleNode("return/@status").getText(); //获取属性status的属性值
/**另一种获取方法*/
Element root = document.getRootElement();
Element r2 = root.element("Result");
org.dom4j.Attribute attribute2 = r2.attribute("Statu");
String attValue = attribute2.getText();
}
