大家一般都是使用dom4j来处理xml文档,不过在使用xpath表达式的时候,会出问题,当然,排除xpath expreesion本身的原因。仔细翻阅dom4j docs,你会发现下面这段话。
===============================================
The dom4j.jar only contains the dom4j classes. If you want to use a SAX parser, you'll have to include the SAX classes and the SAX parser of your choice to your CLASSPATH. If you want to use XPath expressions, you also have to include the jaxen.jar to your CLASSPATH. (注:这里是关键)
dom4j can use your existing XML parser and/or DOM implementation (such as Crimson or Xerces if you want it to. dom4j can also use JAXP to configure which SAX Parser to use - just add the jaxp.jar to your CLASSPATH and whichever SAX parser you wish away you go. ===============================================
原来我们需要导入jaxen.jar 这个jar包。
jaxen.jar是一个用JAVA开发的xpath engine,用于配合各种基于xml的对象模型,如DOM,dom4j和JDOM。
将此包导入到classpath中,就ok 了。
分享到:
相关推荐
dom4j和xpath的jar包,解析xml的最佳拍档.
详细介绍dom4j_xpath,相信对想学dom4j_xpath的朋友有帮助
dom4j 和dom4j 是一款比较好用的Xml解析工具jar,其中部分功能需要xpath的支持
NULL 博文链接:https://wangweiwei358.iteye.com/blog/764548
xml+dom4j+xpath资料
Dom4j 解析XML 所使用的jar包,及添加XPath 支持所需要的 jar 包。具体使用可看我博客
dom4j基础入门文档,与 W3C DOM API 相比,使用 dom4j 所包含的解析器的好处是 dom4j 拥有本地的 XPath 支持。
讲解Dom4j如何利用XPath解析XML
资料来自javaweb学习所得
下面小编就为大家带来一篇在dom4j中使用XPath的简单实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
dom4j和xpath必备jar包对xml文档进行解析的必须jar包!
使用dom4j解析xml时用到的jar包dom4j-1.6.1.zip xpath用到的jar包jaxen-1.1-beta-6.jar
NULL 博文链接:https://a52071453.iteye.com/blog/1708711
用dom4j解析xml时,经常需要用到xpath,由于dom4j-1.6.1.jar不包括jaxen-1.1-beta-6.jar,导致使用xpath报错。 其中jaxen-full.jar是为了解决ava.lang.NoClassDefFoundError: org/jaxen/JaxenException错误。 下载的...
本文介绍如何使用包含在dom4j中的解析器创建并修改XML文档。dom4j API包含一个解析XML文档的工具。本文中将使用这个解析器创建一个示例XML文档,然后使用同一个解析器修改。与W3C DOM API相比,使用dom4j所包含的...
Dom4j_使用简介DOM4J是dom4j.org出品的一个开源XML解析包,它的网站中这样定义: Dom4j is an easy to use, open source library for working with XML, XPath and XSLT on the Java platform using the Java ...
http://www.zvon.org/xxl/XPathTutorial/General_chi/examples.html 的doc文档。
dom4j帮助文档,以及xpath的参考文档,菜鸟必备工具。
dom4j帮助文档 官方API All Classes Packages org.dom4j org.dom4j.bean org.dom4j.datatype org.dom4j.dom org.dom4j.dtd org.dom4j.io org.dom4j.jaxb ...org.dom4j.xpath org.dom4j.xpp
dom4j quick start, xpath 基本用法, junit Test