<XML>

<weibo id="1">

     <Name>张三</Name>

    < Content >哈哈 </ Content >
         < BmiddlePic > http://ww2.sinaimg.cn/bmiddle/9a5e4f09tw1dudkwzh4vkj.jpg
         </ BmiddlePic >
     < CreatedAt > Thu Jun 28 08:42:38 CST 2012 </ CreatedAt >
     < Source > Source </ Source >
    </ weibo >

   </XML>

// 遍历XML
 public void parseXml(File xmlFile) {
  SAXBuilder sax = new SAXBuilder();// 在内存中建立一个sax文档模型
  try {
   Document xmlDom = sax.build(xmlFile);// 创建文档
   // 获得文件的根元素
   Element root = xmlDom.getRootElement();
   System.out.println("根元素是:" + root.getName());

   // 获得根元素的子节点
   
   List childList = root.getChildren();
   Iterator listIt = childList.iterator();
   while (listIt.hasNext()) {
    Element element = (Element) listIt.next();
    System.out.println("第一子节点是:" + element.getName());
   }
   System.out.println("\n\n\n\n");
   
   //遍历所有的第一子节点
   for(int i=0;i<childList.size();i++){
   // 获得第一子节点
   Element firstChild = (Element) childList.get(i);
   // 获得第一子节点属性
   List attrList = firstChild.getAttributes();
   // Iterator attrIt = attrList.iterator();
   // while (attrIt.hasNext()) {
   // Attribute attr = (Attribute) attrIt.next();
   // //System.out.println("第一个元素的属性是:" + attr.getName());
   // // 获得属性的值
   // System.out.println("属性的值是:" + attr.getValue());
   // // 获得属性的类型
   // System.out.println("属性的类型是:" + attr.getAttributeType());
   // }
   List sonList = firstChild.getChildren();
   Iterator sonIt = sonList.iterator();
   int num=0;
    while (sonIt.hasNext()) {
     Element temp = (Element) sonIt.next();
     System.out.println("属性" + temp.getName() + "的值是:"
       + temp.getValue());
     num++;
     if(num==7){
      num=0;
      System.out.println("\n\n");
     }
    }
   }

  } catch (JDOMException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }