在soap响应中获取特定节点值

时间:2013-08-07 07:55:38

标签: xml-parsing

我正在尝试解析此回复                                                             成功                 twss_3ea30fcc6c5b34e                                                        

我这样做了但失败了;

        //parse response
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        org.w3c.dom.Document document = builder.parse(new InputSource(new StringReader(response)));

        XPath xpath = XPathFactory.newInstance().newXPath();
        XPathExpression expr =
                xpath.compile("//o/s/*/text()");
        Object result = expr.evaluate(document, XPathConstants.NODESET);
        //for loop for expr  
        NodeList nodes = (NodeList) result;
        for (int i = 0; i < nodes.getLength(); i++) {
            System.out.println(nodes.item(i).getNodeValue());
        }

如何获取状态和事务I的值?

0 个答案:

没有答案