SAX DOM解析xml

1 获取XML文件的绝对路径
2,BookHandle h=new BookHandle();
3,SAXParserFactory factory=SAXParserFactory.newInstance();
4,SAXParser p=factory.newSAXParser();

5.p.parse(path,h);

DOM(document object model)解析xml
1 SAXReader reader=new SAXReader();
2 Document doc=reader.read(path);
Element e=doc.getRootEllement();
Iterator it=e.attributeIterator();
Attribute a=(Attribute)it.next();
a.getName();
 a.getValue()

转载于:https://my.oschina.net/yourpapa/blog/621604

猜你喜欢

转载自blog.csdn.net/weixin_33873846/article/details/92033259