Java XML教程(二)__教程 |
|
日期:2007-5-20 1:28:01 人气:183 [大 中 小] |
|
|
|
totalEvents + " Events"); }
/** Processing instruction. */ public void processingInstruction(String target, String data) { processingInstructionEvents++; }
/** Start document. */ public void startDocument() { startDocumentEvents++; }
/** Start element. */ public void startElement(String name, AttributeList attrs) { startElementEvents++; }
/** Characters. */ public void characters(char ch[], int start, int length) { characterEvents++; }
/** Ignorable whitespace. */ public void ignorableWhitespace(char ch[], int start, int length) { ignorableWhitespaceEvents++; }
/** End element. */ public void endElement(String name) { endElementEvents++; }
/** End document. */ public void endDocument() { endDocumentEvents++; }
// // ErrorHandler methods //
/** Warning. */ public void warning(SAXParseException ex) { warningEvents++; }
/** Error. */ public void error(SAXParseException ex) { errorEvents++; }
/** Fatal error. */ public void fatalError(SAXParseException ex) throws SAXException { fatalErrorEvents++; throw ex; }
/** Main program entry point. */ public static void main(String argv[]) { if (argv.length == 0) { System.out.println("Usage: java saxCounter uri"); System.out.println(" where uri is the URI of your XML document."); System.out.println(" Sample: java saxCounter sonnet.xml"); System.exit(1); }
saxCounter sc = new saxCounter(); sc.parseURI(argv[0]); } } |
|
出处:本站原创 作者:佚名 |
|
|