清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; public class SAXParserTest extends DefaultHandler{ public SAXParserTest() { super(); } public void startElement(String uri,String localName,String qName,Attributes attr){ if(attr.getLength()>0){ for(int i = 0;i<attr.getLength();i++){ System.out.println(attr.getQName(i)+" = "+attr.getValue(i)); } } } public static void main(String[] args){ try{ //实例化用于分析的工厂 SAXParserFactory factory = SAXParserFactory.newInstance(); //实例化分析类 SAXParser parser = factory.newSAXParser(); SAXParserTest handler = new SAXParserTest(); parser.parse("example.xml",handler); }catch(Exception e){ System.out.println(e.toString()); } } }