Mercurial > hg > RemoteEditor > REPSessionManager
view test/TestSax.java @ 161:5b4be02e7243
*** empty log message ***
author | kono |
---|---|
date | Thu, 28 Aug 2008 16:54:47 +0900 |
parents | 97ca5f5447cd |
children |
line wrap: on
line source
package test; import java.io.StringReader; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.helpers.DefaultHandler; public class TestSax extends DefaultHandler{ public static void main(String[] argv){ String string = null; if(argv.length == 1){ string = argv[0]; } try { SAXParserFactory spfactory = SAXParserFactory.newInstance(); SAXParser parser = spfactory.newSAXParser(); InputSource source = new InputSource(new StringReader(string)); parser.parse(source, new TestSax()); } catch (Exception e) { } } public void startDocument() { System.out.println("Start Document."); } public void startElement(String uri, String loccalName, String qName, Attributes attributes) { System.out.println("Start Element:" + qName); } public void characters(char[] ch, int offset, int length) { System.out.println("Text Data:" + new String(ch, offset, length)); } public void endElement(String uri, String localName, String qName) { System.out.println("End Element:" + qName); } public void endDocument() { System.out.println("End Document"); } }