解析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 ...
随机推荐
- SQL Server中常用的SQL语句
1.概述 名词 笛卡尔积.主键.外键 数据完整性 实体完整性:主属性不能为空值,例如选课表中学号和课程号不能为空 参照完整性:表中的外键取值为空或参照表中的主键 用户定义完整性:取值范围或非空限制,例 ...
- 取出ip address control的ip字符
1.给这个空间设置control型变量 m_add; 2.定义4个字节型变量,来获取控件中的4个ip字节 BYTE a,b,c,d: m_add.GetAddress(a,,b,c,d): 3.定义I ...
- 使用VS2010开发Qt程序的一点经验(转载)
转载:http://www.cnblogs.com/csuftzzk/p/VS_Qt_Experience.html 导读 相比于Qt Creator,我更喜欢用VS2010来进行开发.虽然启动时间相 ...
- 在JSP页面中输出字符" * "组成的金字塔
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 【leetcode❤python】121. Best Time to Buy and Sell Stock
#-*- coding: UTF-8 -*- #Method1 :超时#class Solution(object):# def maxProfit(self, prices):# # ...
- Logical Address->Linear Address->Physical Address
3 registers for starting pos: LDTR, GDTR( register for starting addr of DT) ---段描述符每个段由一个8字节(64位)的段描 ...
- Oracle 分页实现
--分页实现------实行两行一页 --1 先查询按编号排序的所有用户信息 select t.* from T_USER t order by user_id ; --2 查询数据的前四行, ; - ...
- mybatis的基本配置:实体类、配置文件、映射文件、工具类 、mapper接口
搭建项目 一:lib(关于框架的jar包和数据库驱动的jar包) 1,第一步:先把mybatis的核心类库放进lib里
- C# 操作的时候接收用户输入密码进行确认
首先新建一个原始窗体,如下:
- vs无法打开项目的解决方案
错误提示: “未找到与约束 ContractName Microsoft.Internal.VisualStudio.PlatformUI.ISolutionAttachedCollectionSer ...