import java.io.File;
import java.io.FileNotFoundException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class ResolveXmlFile {
public void resolverXml() throws DocumentException, FileNotFoundException{
//读取xml文件 来得到document
SAXReader reader = new SAXReader();
Document document = reader.read(new File("F://Workspaces//DomXmlProject//src//T_AR_OtherBillentry.xml"));
Element root = document.getRootElement();
//循环根节点
for(java.util.Iterator it =root.elementIterator("columns");it.hasNext();){
Element elm=(Element)it.next();
//循环子节点
for(java.util.Iterator it1 = elm.elementIterator("column");it1.hasNext();){
Element elm1 =(Element)it1.next();
Element name=elm1.element("name"); //取得节点
Element type=elm1.element("sqlType"); //取得节点
System.out.println(name.getData().toString()+type.getData().toString());
}
}
}
public static void main(String[] args) throws DocumentException, FileNotFoundException{
ResolveXmlFile rx = new ResolveXmlFile();
rx.resolverXml();
}
}