`
cuisuqiang
  • 浏览: 3937504 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
3feb66c0-2fb6-35ff-968a-5f5ec10ada43
Java研发技术指南
浏览量:3651857
社区版块
存档分类
最新评论

Xpath java.lang.NoClassDefFoundError: org/jaxen/JaxenException

    博客分类:
  • J2EE
阅读更多

要解析一个XML文件,如下进行解析 

 

	public static void main(String[] args) throws Exception {
		String xmlpath = DomParse.class.getResource("blackhawk.xml").toString();
		SAXReader reader = new SAXReader();
		Document document = reader.read(xmlpath);
		List projects = document.selectNodes("/blackhawk/disk/uploadPath");
		Iterator it = projects.iterator();
		while (it.hasNext()) {
			Element elm = (Element) it.next();
			System.out.println(elm.getText());
		}
	}

 

 

使用dom4j时报错 

	java.lang.NoClassDefFoundError: org/jaxen/JaxenException 
	at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:196) 
	at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:205) 
	at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:161) 
	at xml.Dom4jDemo.readTest(Dom4jDemo.java:223) 
	at xml.Dom4jDemo.main(Dom4jDemo.java:188) 

 

 

 

 

很简单是没有找到类,可是使用dom4j只需一个包,怎么会缺类呢

原来

List projects = document .selectNodes("/blackhawk/disk/uploadPath"); 

 

 

 

 

其实这里我使用了XPath进行定位查询节点,而Xpath其实不是dom4j的东西,而是一个标准,使用它需要进入如下两个包

  jaxen-full.jar  
      saxpath.jar

这样才可以使用XPath

可是令我郁闷的是,既然你dom4j是解析xml的,而XPath是如此重要的一个东西,你对它支持的又是如此的好,可你的官方包里为什就是没有加入这两个包呢?

分享到:
评论
1 楼 xiaomimishiye 2011-01-03  
谢了,哥们!

相关推荐

    xom-1.1.jar

    org/jaxen/XPath.class 1.04 KB org/jaxen/XPathFunctionContext.class 3.52 KB org/jaxen/XPathSyntaxException.class 1.52 KB org/jaxen/expr/ org/jaxen/expr/AdditiveExpr.class 198.0 bytes org/...

    xpath在java中要类jaxen.jar

    恶心的问题,java.lang.NoClassDefFoundError: org/jaxen/JaxenException 分类: xml 问题 2011-12-29 13:28 0人阅读 评论(0) 收藏 编辑 删除 原来什么问题都没有,就是没有用那个jaxen.jar这个包 可以从...

    用dom4j解析xml时,用xpath的辅助包

    其中jaxen-full.jar是为了解决ava.lang.NoClassDefFoundError: org/jaxen/JaxenException错误。 下载的rar包内容有: dom4j-1.6.1.jar jaxen-1.1-beta-6.jar jaxen-full.jar 如果大家有好的建议或方法及时告诉我,...

    jaxen-1.1-beta-6.jar

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230) at org.dom4j.tree.AbstractNode.createXPath...

    XPathTutorialDoc

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230) at org.dom4j.tree.AbstractNode.createXPath...

    dom4j-1.6包

    Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230) at org.dom4j.tree.AbstractNode.createXPath...

    Python爬虫Scrapy框架使用

    xpath:http://www.w3school.com.cn/xpath/index.asp 制作爬虫 安装scrapy环境: pip install Scrapy 新建项目(命令行:scrapy startproject xxx):新建一个爬虫项目 明确目标(编写items.py):明确你想要抓取...

    01-xpath示例.py

    from lxml import etree html = """<div class="wrapper"> <i class="iconfont icon-back" id="back"></i> <a href="/" id="channel">新浪社会</a> <li><a href="http://domestic.firefox.sina.com/" title="...

    HTML抽取器Xsoup.zip

    同时Xsoup提供全面的XPath解析错误提示。 示例代码: @Test public void testSelect() { String html = "<html><div><a href='https://github.com'>github.com</a></div></html>"; ...

    lazyuiautomatorviewer

    可生成app控件唯一相对Xpath 1.如果只包含resource-id,且唯一,则直接用resource-id,其Xpath为://android.XX.XXX[@resource-id=\"com.duowan.mobile:id/rb_main\"] 2.如果只存在text,且唯一,则直接用text,其...

    lazyuiautomatorviewer 增强版uiautomatorviewer

    增强版uiautomatorviewer 可生成app控件唯一相对Xpath 1.如果只包含resource-id,且唯一,则直接用resource-id,其Xpath为://android.XX.XXX[@resource-id=\"com.duowan.mobile:id/rb_main\"] 2.如果只存在text,且...

    (全)传智播客PHP就业班视频完整课程

    9-6 4.php xml编程⑨-综合练习-基于xml的在线词典 phpdom使用xpath 9-6 5.php xml编程(10)-SimpleXML 9-7 1.回顾 9-7 2.析构方法 9-7 3.static关键字(静态变量) 9-7 4.static关键字(静态方法) 面向对象编程三大特性...

    Nux 1.6- 高效处理xml

    Nux是一个开源的Java工具,它能够让XML高效处理变得容易。Nux可嵌入到具有高吞吐量的XML消息中间件中比如:大型p2p底层结构,消息队 列,发布-订阅和Blogs/新闻聚合的matchmaking系统,分布式系统,防火墙等.Nux集成并...

    android APP元素捕捉工具

    uiautomatorviewer 添加xpath属性,三种方法 如: xpath : //android.widget.Button[@resource-id=\"com.android.huayi:id/btn_download_update_dialog\"] uiseletor:new UiSelector().className(\"android.widget....

    webharvest 中文翻译文档

    2. 一个介绍XPath、XQuery 以及 XSLT 函数的网址 http://www.w3school.com.cn/xpath/xpath_functions.asp 3. 另一个参考地址 http://www.ibm.com/developerworks/cn/xml/x-xqueryl/ 可以在XML相关书籍中找到实例。 ...

    XPathHelper.rar

    XPath-Helper是用来在页面上快速定位元素的一个插件,方便爬虫的时候编写解析代码。详情可见我的博客:https://blog.csdn.net/qq_23521659/article/details/101541648

    基于Springboot+Vue的房价可视化监测系统源码+项目说明.zip

    爬虫部分:[Xpath](https://www.w3.org/TR/xpath/)(Python爬虫核心模块)、[ProxyPool](https://github.com/jhao104/proxy_pool)(Python爬虫IP代理池) 定时任务:[xxl-job](https://github.com/xuxueli/xxl-job/...

    基于Selenium的WebUI自动化测试框架pyse.zip

    特点:支持多种定位方法(id\name\class\link_text\xpath\css)。本框架只是对 selenium( webdriver ) 原生方法进行了简单的封装,精简为大约 30 个方法,这些方法基本能够胜任于我们的web自动化测试。基于 ...

    XPath Helper.crx

    xpath helper插件是一款免费的chrome爬虫网页解析工具。可以帮助用户解决在获取xpath路径时无法正常定位等问题。该插件主要能帮助你在各类网站上通过按shift键选择想要查看的页面元素来提取查询其代码,同时你还能对...

Global site tag (gtag.js) - Google Analytics