1

同様の質問に回答したことは知っていますが、それらは私の特定の問題に完全には対応していません。

public String getValue(String xPath) {
    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(new PersonalNamespaceContext());
    String value = null;
    NodeList nodes = null;
    try {
        XPathExpression expr = xpath.compile(xPath);
        nodes = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
        System.out.println("nodes: " + nodes.getLength());
    } catch (XPathExpressionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    for (int idx = 0; idx < nodes.getLength(); idx++) {
        value = nodes.item(idx).getTextContent();
        System.out.println(value);
        //break;
    }
    return value;
}

「表示されている」テキストノードの値を取得できる必要があります。

                 <itemlocation>
                    <x>0</x>
                    <y>0</y>
                 </itemlocation>
                 <visible>off</visible>
              </pane>

それを行うための正しいxPath値が見つからないようです。誰か考えがありますか?

4

0 に答える 0