/** * 按照字符串的方式,解析 xml 文件 */ public static void parserXML() { //按文件的方式,读取xml, getFile这个方法自行创建。 String xml = UseTools.getFile("newapplication_10.xml"); //将字符串转换为StringReader StringReader xmlString = new StringReader(xml); InputSource source = new InputSource(xmlString); try { //使用 jdom 解析 SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(source); //获得xml的 root 节点 Element rootEle = doc.getRootElement(); System.out.println(rootEle.getName()); } catch(Exception e) { } }
java 解析 xml
猜你喜欢
转载自vissed.iteye.com/blog/1827018
今日推荐
周排行