posts - 21,  comments - 6,  trackbacks - 0
          ?1 package ?cn.com;
          ?2
          ?3 import ?java.io.FileInputStream;
          ?4 import ?java.io.FileNotFoundException;
          ?5 import ?java.io.IOException;
          ?6 import ?java.util.List;
          ?7
          ?8 import ?org.jdom.Document;
          ?9 import ?org.jdom.Element;
          10 import ?org.jdom.JDOMException;
          11 import ?org.jdom.input.SAXBuilder;
          12
          13 public ? class ?MyJDom? {
          14 ???? public ? static ? void ?main(String[]?args)? throws ?FileNotFoundException,?JDOMException,?IOException? {
          15 ????????SAXBuilder?sab? = ? new ?SAXBuilder();
          16 ????????Document?doc? = ?sab.build( new ?FileInputStream( " ./data/myjdom.xml " ));
          17 ????????
          18 ????????Element?element? = ?doc.getRootElement();
          19 ????????List?list? = ?element.getChildren();
          20 ????????
          21 ???????? for ( int ?i = 0 ;?i < list.size();?i ++ )? {
          22 ????????????System.out.println( " ------------ " );
          23 ????????????
          24 ????????????Element?ele2? = ?(Element)?list.get(i);
          25 ????????????String?id? = ?ele2.getAttribute( " id " ).getValue();
          26 ????????????System.out.println( " ID===>>> " ? + ?id);
          27 ????????????
          28 ????????????Element?ele3? = ?ele2.getChild( " title " );
          29 ????????????String?title? = ?ele3.getText();
          30 ????????????System.out.println( " Title===>>> " ? + ?title);
          31 ????????}

          32 ????}

          33 }

          34
          posted on 2006-09-25 14:48 Warren.Wu 閱讀(545) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 那曲县| 广平县| 盐源县| 上思县| 东乡| 峡江县| 仲巴县| 花莲市| 天门市| 井冈山市| 普定县| 兰坪| 东至县| 合肥市| 贵州省| 井陉县| 水城县| 扶沟县| 泾阳县| 宜春市| 新河县| 承德县| 中西区| 乌兰县| 沧州市| 泌阳县| 黄大仙区| 大庆市| 阳朔县| 安阳县| 富源县| 普洱| 吐鲁番市| 东阳市| 沁阳市| 东至县| 岢岚县| 台湾省| 陆川县| 长葛市| 石台县|