处理带名称空间XML的XPATH

来源:互联网 发布:做会计报表的软件? 编辑:程序博客网 时间:2024/04/29 06:14

    Document document = DocumentHelper
     .parseText(getResponseBodyAsString());
   String xpathExpression = "//" + XML_WBXC_MULTISTATUS + "/"
     + XML_WBXC_TASKSTATUS + "/" + XML_WBXC_TASK + "/" + tag;
   XPath xpath = DocumentHelper.createXPath(xpathExpression);
   HashMap<String, String> hashMap = new HashMap<String, String>();
   hashMap.put(XML_WBXC_NAMESPACE, XML_WBXC_NAMESPACE_URL);
   xpath.setNamespaceURIs(hashMap);
   Node node = xpath.selectSingleNode(document);
   if (node != null)
    return node.getText();