首页 dom4j获取指定节点1

dom4j获取指定节点1

举报
开通vip

dom4j获取指定节点1Xml文件ffnullnull02013-11null1232013-11-252013-11-261233nullnull02013-11null2013-11-252013-11-2521312

dom4j获取指定节点1
Xml文件ffnullnull02013-11null1232013-11-252013-11-261233nullnull02013-11null2013-11-252013-11-2521312null1232013-11-252013-11-25nullD:/w2.jpgnullnull23null1232013-11-252013-11-25nullnullnullnull122013-11-2521时32分飞机nullD:/w2.jpgnullnullnull实体类packagecom.test;importjava.io.File;importjava.util.List;importorg.dom4j.Document;importorg.dom4j.Node;importorg.dom4j.io.SAXReader;importcom.xcfh.usermanager.service.UserManagerService;publicclassTestXML3{publicstaticvoidmain(String[]args){//traffic_info other_info stay_infogetImages("stay_info","w2.jpg");}/*publicstaticvoidgetImage(Stringtype,StringimageName){Stringstrxml="D:\\test.xml";StringimagePath="D:/w2.jpg";try{Filefile=newFile(strxml);SAXReaderreader=newSAXReader();Documentdoc=reader.read(file);Elementroot=doc.getRootElement();if(imagePath.substring((imagePath.lastIndexOf("/")1)).equals(imageName)){imageName=imagePath;//Stringtext1="//bookstore[@name='"infoname"']/*[title_id=\'"fName"']";Stringtext="//table[@name='"type"']/*[stay_invoice_local_path='"imageName"']";System.out.println(text);Listnode=doc.selectNodes(text);System.out.println(node.get(0).getName());System.out.println(node.get(0).selectSingleNode("stay_invoice_local_path").getText());}}catch(Exceptione){e.printStackTrace();}}*/publicstaticvoidgetImages(Stringtype,StringimageName){Stringstrxml="D:\\test.xml";try{Filefile=newFile(strxml);SAXReaderreader=newSAXReader();Documentdoc=reader.read(file);Listnode=doc.selectNodes("//table[@name='"type"']/*");for(Noden:node){//System.out.println(n.getName());if("stay_info".equals(type)){Stringstay_invoice_local_paths=n.selectSingleNode("stay_invoice_local_path").getText();//System.out.println(stay_invoice_local_paths);if(stay_invoice_local_paths.substring(stay_invoice_local_paths.lastIndexOf("/")1).equals(imageName)){imageName=stay_invoice_local_paths;//System.out.println(imageName"--------------");Stringtext="//table[@name='"type"']/*[stay_invoice_local_path='"imageName"']";Listnode1=doc.selectNodes(text);//System.out.println(node1.get(0).getName()"\t--------------");System.out.println(node.get(0).selectSingleNode("stay_invoice_local_path").getText());}}if("traffic_info".equals(type)){Stringtraffic_invoice_local_paths=n.selectSingleNode("traffic_invoice_local_path").getText();if(traffic_invoice_local_paths.substring(traffic_invoice_local_paths.lastIndexOf("/")1).equals(imageName)){imageName=traffic_invoice_local_paths;Stringtext="//table[@name='"type"']/*[traffic_invoice_local_path='"imageName"']";Listnode1=doc.selectNodes(text);System.out.println(node.get(0).selectSingleNode("traffic_invoice_local_path").getText());}}if("other_info".equals(type)){Stringother_invoice_local_paths=n.selectSingleNode("other_invoice_local_path").getText();if(other_invoice_local_paths.substring(other_invoice_local_paths.lastIndexOf("/")1).equals(imageName)){imageName=other_invoice_local_paths;Stringtext="//table[@name='"type"']/*[other_invoice_local_path='"imageName"']";Listnode1=doc.selectNodes(text);System.out.println(node.get(0).selectSingleNode("other_invoice_local_path").getText());}}}  }catch(Exceptione){e.printStackTrace();}}}
本文档为【dom4j获取指定节点1】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_511210
暂无简介~
格式:doc
大小:31KB
软件:Word
页数:13
分类:
上传时间:2022-09-11
浏览量:1