欢迎来到天天文库
浏览记录
ID:6760058
大小:33.00 KB
页数:7页
时间:2018-01-24
《java 的xml编程sax解析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JAVA的XML编程SAX解析JAVA鐨刋ML缂栫▼SAX瑙f瀽鍒嗙被锛?J2SE2009-02-1822:35413浜洪槄璇?璇勮(0)鏀惰棌涓炬姤SAX涓昏鏄互涓茶鍜屽眰娆$殑鏂瑰紡杩涜瑙f瀽锛屽涓嬫槸涓€涓緢绠€鍗曠殑瑙f瀽渚嬪瓙锛?1銆侀€夋嫨涓€涓瑙f瀽鐨剎ml鏂囨。[java]viewplaincopy2、.oreilly.com/javaxml2"xmlns:ora="http://www.oreilly.com"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.oreilly.com/javaxml2XSD/contents.xsdhttp://www.oreilly.comXSD/contents-ora.xsd">JavaandXML4、cname="Transformations"/><5、/book>2銆佷娇鐢⊿AX杩涜瑙f瀽锛屼唬鐮佸涓嬶細[java]viewplaincopypackagejavaxml2;importjava.io.IOException;importjava.io.OutputStreamWriter;importorg.xml.sax.Attributes;importorg.xml.sax.ContentHandler;importorg.xml.sax.InputSource;importorg.xml.sax.Locator;importorg.xml.sax.SAXException6、;importorg.xml.sax.XMLReader;importorg.xml.sax.helpers.DefaultHandler;importorg.xml.sax.helpers.XMLReaderFactory;publicclassMySaxXmlextendsDefaultHandler{/***@paramargs*@throwsSAXException*@throwsException*/privateLocatorlocator;privateintindex1=0;privateintindex2=0;publ7、icvoidcharacters(char[]ch,intstart,intlength)throwsSAXException{//TODO鑷姩鐢熸垚鏂规硶瀛樻牴//System.out.print("SAXEvent:CHARACTERS[");System.out.print("鏈功<<");try{OutputStreamWriteroutw=newOutputStreamWriter(System.out);outw.write(ch,start,length);outw.flush();}catch(Exceptione)8、{e.printStackTrace();}System.out.println(">>鐨勭洰褰?);//System.out.println("]");}publicvoidendDocument()th
2、.oreilly.com/javaxml2"xmlns:ora="http://www.oreilly.com"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.oreilly.com/javaxml2XSD/contents.xsdhttp://www.oreilly.comXSD/contents-ora.xsd">JavaandXML4、cname="Transformations"/><
4、cname="Transformations"/>
5、/book>2銆佷娇鐢⊿AX杩涜瑙f瀽锛屼唬鐮佸涓嬶細[java]viewplaincopypackagejavaxml2;importjava.io.IOException;importjava.io.OutputStreamWriter;importorg.xml.sax.Attributes;importorg.xml.sax.ContentHandler;importorg.xml.sax.InputSource;importorg.xml.sax.Locator;importorg.xml.sax.SAXException
6、;importorg.xml.sax.XMLReader;importorg.xml.sax.helpers.DefaultHandler;importorg.xml.sax.helpers.XMLReaderFactory;publicclassMySaxXmlextendsDefaultHandler{/***@paramargs*@throwsSAXException*@throwsException*/privateLocatorlocator;privateintindex1=0;privateintindex2=0;publ
7、icvoidcharacters(char[]ch,intstart,intlength)throwsSAXException{//TODO鑷姩鐢熸垚鏂规硶瀛樻牴//System.out.print("SAXEvent:CHARACTERS[");System.out.print("鏈功<<");try{OutputStreamWriteroutw=newOutputStreamWriter(System.out);outw.write(ch,start,length);outw.flush();}catch(Exceptione)
8、{e.printStackTrace();}System.out.println(">>鐨勭洰褰?);//System.out.println("]");}publicvoidendDocument()th
此文档下载收益归作者所有