-
利用XPathUtil,根据Xpath对xml文件进行解析
资源介绍
根据xmlPath路径,找到对应的xml文件,进行解析!之前找了好多感觉和自己的需求不太一样,这个可以根据Xpath解析出来xml里所有的信息,十分好用
举个例子
xmlPath = "E://upload/xml/1580242.163.xml";
XPathUtil util = XPathUtil.newInstance(xmlPath);
Product product = new Product();
String title = util.getSingleValue("book/title");
product.setTitle(title);
String classification = util.getSingleValue("/book/info/classification");
product.setFenlei(classification);
String language = util.getSingleValue("/book/info/language");
String yuYan = XPathUtil.LANUAGE_MAP.get(language);
product.setYuYan(yuYan);
String personname =util.getSingleValue("/book/info/authorgroup/author/personname");
String role = util.getDomAttribute("/book/info/authorgroup/author", "role");
String author = personname + " " + role;
product.setAuthor(author);
String personblurb = util.getSingleValue("/book/info/authorgroup/author/personblurb");
product.setAuthorRemarks(personblurb);
- 上一篇: jQuery Bootstrap响应式下拉菜单
- 下一篇: html5手机网站侧边栏导航代码.zip