在Dom4j中使用xpath出错的原因

       

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值