org.dom4j.InvalidXPathException: Invalid XPath expression: '/html'. Caused by: org/dom4j/Element
这是什么原因?
这样写xpath("/html")没有错吧。
======================
解决办法,去掉/jre/lib/ext/目录下的jaxen.jar包,把该jar包放在classpath目录下。[之所以把这个包放在这个目录下,原因是看到源码中的INSTALL文档如下描述的]
INSTALL 写道
To install Jaxen, you need to place:
jaxen-1.1.3.jar
In your CLASSPATH or your jre/lib/ext directory.
This includes support for all object-models.
Of course, you'll also need the supporting jars for your
object-model, such as jdom.jar, xom.jar, or similar.
bob@werken.com
jaxen-1.1.3.jar
In your CLASSPATH or your jre/lib/ext directory.
This includes support for all object-models.
Of course, you'll also need the supporting jars for your
object-model, such as jdom.jar, xom.jar, or similar.
bob@werken.com
maven的pom.xml之间去掉对dom4j依赖,添加对jaxen的依赖,避免dom4j的重复?。
至此,该问题解决了。知道具体原因后在完善。
=================================
在用xpath解析由html转化的xml时,为什么正确的xpath表达式却得不到匹配的值?
需要注意的是名字空间,参看下面这篇文章,有两种办法。
关于dom4j无法解析xmlns问题及生成非UTF-8字符集乱码问题的解决
http://blog.csdn.net/shadowkiss/archive/2009/06/15/4269816.aspx
留下问题:为什么名字空间会影响到xpath规则?