解决方案 »

  1.   

    调试下看看都包含了什么值 以下工厂方式供参考 
    DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
                DocumentBuilder builder = fac.newDocumentBuilder();
                Document doc = builder.parse(new File("aa.xml"));
                XPathFactory pathFactory = XPathFactory.newInstance();
                XPath path = pathFactory.newXPath();
                NodeList list = (NodeList) path.evaluate("//product/colour", doc,
                        XPathConstants.NODESET);            for (int i = 0; i < list.getLength(); i++) {
                    System.out.println(list.item(i).getTextContent());
                }