以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  使用dom4j中xpath错误  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=22969)


--  作者:laixiaonian
--  发布时间:10/12/2005 10:30:00 AM

--  使用dom4j中xpath错误
我的代码是
try{

        SAXReader saxReader = new SAXReader();

        Document document = saxReader.read(new File(filename));

        /** 修改内容之一: 如果book节点中show属性的内容为yes,则修改成no */

        /** 先用xpath查找对象 */

        List list = document.selectNodes("//books/book/@show" );

        Iterator iter = list.iterator();

        while(iter.hasNext()){

           Attribute attribute = (Attribute)iter.next();

           if(attribute.getValue().equals("yes")){

               attribute.setValue("no");

           }   

        }
用eclipse编译
报错
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)
 at com.sm.xml.domj4.Dom4jDemo.ModiXMLFile(Dom4jDemo.java:178)
 at com.sm.xml.domj4.Dom4jDemo.main(Dom4jDemo.java:63)
Exception in thread "main"
它说是
List list = document.selectNodes("//books/book/@show" ); 行有错
我换成/books/book/@show也报同样的错误,换成/books/book/show也报同样的错误
哪为也遇到过同样的问题,帮帮我


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
15.625ms