标签:
xml文件:
<wc:COLLECTION xmlns:wc="http://www.ptc.com/infoengine/1.0"> <Unknown-Class-Name NAME="output" TYPE="Unknown" STATUS="0"> <wc:INSTANCE> <result>ok</result> <data>铭牌KFR-26GW$DY-PC400(D13).PM-1.pdf,377.04</data> </wc:INSTANCE> </Unknown-Class-Name> </wc:COLLECTION> |
代码:
SAXReader saxReader = new SAXReader(); Document document; try { document = saxReader.read(new File("test.xml")); Node node = document.selectSingleNode("//*/data"); System.out.println(node.getText()); } catch (DocumentException e) { e.printStackTrace(); }
需要的jar包:
标签:
原文地址:http://www.cnblogs.com/wurainren/p/4773176.html