Chinaunix首页 | 论坛 | 博客
  • 博客访问: 182089
  • 博文数量: 88
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 914
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-10 13:41
文章分类

全部博文(88)

文章存档

2010年(2)

2009年(35)

2008年(51)

我的朋友

分类: Java

2009-10-27 17:58:55

 





 
  ---------------------------------------------------------
  SAXReader reader = new SAXReader();
        try {
            Document doc = reader.read("src/main/java/test.xml");

            List items = doc.selectNodes("/file/chapter");
            Iterator it = items.iterator();

            while (it.hasNext()) {
                Element el = (Element) it.next();

                if ((!(el.attributeValue("id") == null) || !el.attributeValue(
                        "id").equalsIgnoreCase(""))) {

                }
                Attribute attId = el.attribute("id");
                System.out.print("id:" + attId.getValue() + " ");
                Attribute attName = el.attribute("name");
                System.out.println("name:" + attName.getValue());

            }

        } catch (DocumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

----------------------------------------------------
    xsi:schemaLocation=" ">
    4.0.0
    com.travelsky.dom4j
    dom4jProj
    jar
    1.0-SNAPSHOT
    dom4jProj
   
   
       
            junit
            junit
            3.8.1
            test
       

       
            dom4j
            dom4j
            1.6.1
            provided 
       

       
            icu4j
            icu4j
            2.6.1
            provided 
       

       
            jaxen
            jaxen
            1.1.1
            provided 
       

       
            jdom
            jdom
            1.0
            compile
       

       
            xalan
            xalan
            2.6.0
            compile
       

       
            xerces
            xercesImpl
            2.6.2
            provided 
       

       
            xml-apis
            xml-apis
            1.0.b2
            provided 
       

       
            xerces
            xmlParserAPIs
            2.6.2
            provided 
       

           
            xom
            xom
            1.0
            compile
       

   


   
        dom4jApp
       
           
                org.apache.maven.plugins
                maven-compiler-plugin
               
               
                    1.4
                    1.4
                    UTF-8
               

           

     
           
                org.apache.maven.plugins
                maven-javadoc-plugin
               
                    UTF16
               

           

       

   




阅读(1982) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~