/* * $Id: MyDocumentHandler.java,v 1.1 2002/04/16 18:07:01 aslom Exp $ * * (C) Copyright 2002 by Yuval Oren. All rights reserved. * (C) Copyright 2002 by Aleksander Slominski. All rights reserved. * Modified from initial version by * Aleksander Slominski * * This software is released under the terms of the * GNU General Public License (GPL). Full * text is available at http://www.gnu.org/licenses/gpl.html */ import org.xml.sax.*; import org.xml.sax.helpers.*; public class MyDocumentHandler implements DocumentHandler { StringBuffer buf = new StringBuffer(); public void characters(char[] ch, int start, int length) throws SAXException { // for (int i=0; i < length; i++) // System.out.print("["+ch[start+i]+"]"); buf.append(ch, start, length); } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { // for (int i=0; i < length; i++) // System.out.print("{"+ch[start+i]+"}"); buf.append(ch, start, length); } public void endElement(String name) throws SAXException { // System.out.print(""); String c = buf.toString(); } public void processingInstruction(String target,String data) throws SAXException { // System.out.print(""); } public void startElement(String name, AttributeList attr) throws SAXException { // System.out.print("<" + name); int len = attr.getLength(); for (int i=0; i < len; i++) { String n = attr.getName(i); String t = attr.getType(i); String v = attr.getValue(i); // System.out.println(" "+n+"(type:"+t+")=\""+v+"\""); } // System.out.print(">"); buf.setLength(0); } public void startDocument() { } public void endDocument() { } public void setDocumentLocator(Locator l) { } }