dom4j 解析xml字符串 去除.DTD校验


   String xmlDoc = "";
   xmlDoc = xmlDoc.replace("", "");
   Document doc = null;
      try {
   doc = DocumentHelper.parseText(xmlDoc);
  } catch (DocumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } // 将字符串转为XML
     Element rootElt = doc.getRootElement(); // 获取根节点
//     Element TAXPAYER = (Element)rootElt.selectSingleNode("//TAXPAYER"); 
//     Element Records = (Element)TAXPAYER.selectSingleNode("//Records");
     List RecordList = rootElt.selectNodes("//Record");
     try {
      if(RecordList.size()>0){
	
        for (int i = 0; i < RecordList.size(); i++) {
         e = (Element) RecordList.get(i);
         System.out.println("-e-"+e.attributeValue("FPHM"));
        }

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

你可能感兴趣的:(xml解析,xml)