0

私はこの機能を実行しようとしています:

public static void main(String[] args) 
            throws ParserConfigurationException, SAXException, 
            IOException, XPathExpressionException {
                DocumentBuilderFactory domFactory = 
                DocumentBuilderFactory.newInstance();
                domFactory.setNamespaceAware(true); 
                DocumentBuilder builder = domFactory.newDocumentBuilder();
                Document doc = builder.parse("res/raw/test.xml");
                XPath xpath = XPathFactory.newInstance().newXPath();
                // XPath Query for showing all nodes value
                XPathExpression expr = xpath.compile("//station/*/text()");

                Object result = expr.evaluate(doc, XPathConstants.NODESET);
                NodeList nodes = (NodeList) result;
                for (int i = 0; i < nodes.getLength(); i++) {
                    System.out.println("zoekdit");
                    System.out.println(nodes.item(i).getNodeValue()); 
                }
             }

だから私はそれをクラスに入れました: MainActivity. しかし、logcat で検索すると、「zoekdit」が見つかりません...

4

1 に答える 1