`
slowman
  • 浏览: 37789 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

在Dom4j中使用xpath出错的原因

    博客分类:
  • J2EE
阅读更多

       

    大家一般都是使用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 了。

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics