XPath是您的正确选择:
documentBuilderFactory factory = documentBuilderFactory.newInstance();documentBuilder builder = factory.newdocumentBuilder();document doc = builder.parse("<Your xml doc uri>");XPathFactory xPathfactory = XPathFactory.newInstance();XPath xpath = xPathfactory.newXPath();XPathexpression expr = xpath.compile("//Type[@type_id="4218"]");NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
并遍历
nl
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)