解析xml报classnotfound错误
使用dom4j解析XML时,要快速获取某个节点的数据,使用XPath是个不错的方法,dom4j的快速手册里也建议使
用这种方式,
方法是使用Document的selectNodes(String XPath)方法,
selectSingleNode(String XPath)
代码写法:
List<?> list = document.selectNodes("//books/book");
执行时却抛出以下异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164)
这么好用的方法怎么能抛异常呢,一路跟踪过去看,竟然是“List l = doc.selectNodes("//COLS/COL1");”
这句报错,查了一下才知道,不光要有dom4j这个包,还要有jaxen 包:<jaxen-1.1-beta-6.jar>,这
应该是dom4j的基础包,在dom4j的zip包的lib目录里可以找到。即使用这个方法需要以下两个包:
dom4j-1.6.1.jar
jaxen-1.1.jar
解析xml报classnotfound错误的更多相关文章
- 【Maven】运行项目,报ClassNotFound错误
我们在pom.xml中添加了那些依赖的jar后,一旦在代码中应用.当我们本地调试时,会报ClassNotFound错误,这是为什么?? 因为Tomcat不懂这些配置,你必须把Maven Depende ...
- DOM解析XML报错:Content is not allowed in prolog
报错内容为: Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. 网上所述总结来 ...
- 用dom4j解析xml 报java.lang.NoClassDefFoundError:org/jaxen/JaxenException
转自:http://www.myexception.cn/java%20exception/95.html 源码如下: import java.io.File; import java.util.Li ...
- dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.
采用dom4j方式解析string类型的xml xml: String string="<?xmlversion=\"1.0\" encoding=\ ...
- dom4j解析xml报"文档中根元素后面的标记格式必须正确"
今天,在写个批量启动报盘机的自动化应用,为了简化起见,将配置信息存储在xml中,格式如下: <?xml version="1.0" encoding="UTF-8& ...
- dom4j解析xml时报出文件提前结束
在写javaweb小项目的时候,用dom4j解析xml报出如下错误: org.dom4j.DocumentException:Error ....... Nested exception: ...
- Python读取xml报错解析--ExpatError: not well-formed (invalid token)
xml文件内容如代码所示存入的名字为login.xml: <?xml version="1.0" encoding="utf-8"?> <in ...
- 解析xml字符串时报“前言中不允许有内容”错误。
一,问题出现经过: j基于java语言webservic服务端接收客户端 传来的xml字符串用 解析时总报:org.dom4j.DocumentException: Error on line 1 o ...
- Received non-all-whitespace CHARACTERS or CDATA event in nextTag(). ,无法整齐打印验证错误。 解析XML文档出现的问题
在启动keyCloak,想要在standAlone模式下切换数据库,修改standAlone.xml文件时. 在bin/目录下启动standAlone模式出现错误: 10:07:24,799 INFO ...
随机推荐
- 在 Server 端存取 Excel 檔案的利器:NPOI Library
转处 http://msdn.microsoft.com/zh-tw/ee818993.aspx Codeplex 軟體套件(Package)資訊 套件名稱 NPOI 作者 tonyqus, huse ...
- stuts-security.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "- ...
- 编译android源码官方教程(2)建立编译环境「linux & mac osx」
https://source.android.com/source/initializing.html Establishing a Build Environment IN THIS DOCUMEN ...
- Struts2框架的运行流程
Struts2的运行流程 1.浏览器发送请求到控制器(如Struts2中的核心控制器StrutsPrepareAndExecuteFilter): 2.控制器调用Action的execute方法: 3 ...
- XMPP Server
XMPPFramework,编译失败,@import libxmlSimu后提示:Module 'libxmlSimu' not found XMPP协议实现原理介绍 XMPP协议学习笔记 四.地址格 ...
- U盘安装CentOS7的最终解决方案
转载自http://www.augsky.com/599.html 终于将CentOS7装上笔记本了,过程无比艰辛,因为我发现网上大家提到的所有U盘安装CentOS7时碰到的问题几乎都被我碰到了,像什 ...
- HDU 4870 Rating 概率DP
Rating Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- php cookie详解
各参数详解 注意: 1 当一个Cookie被删除时,它的值在当前页在仍然有效的.原因是删除cookie实际也是设置cookie, 只是把cookie的值设为‘’或者null,或者把cookie的 ...
- ALV详解:OO ALV
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- CUBRID学习笔记 28 执行sql脚本文件
一下命令在csql下执行. insert_commands.sql为sql脚本文件 ;CL ;READ insert_commands.sql ;RU 第一行的cl 清空命令缓存,等同clear第二行 ...