edu.pdx.cs399J.xml
Class PrintPhoneNumbers
java.lang.Object
org.xml.sax.helpers.DefaultHandler
edu.pdx.cs399J.xml.PrintPhoneNumbers
- All Implemented Interfaces:
- ContentHandler, DTDHandler, EntityResolver, ErrorHandler
public class PrintPhoneNumbers
- extends DefaultHandler
This program demonstrates the SAX parsing API by parsing a
phonebook XML document and printing out the phone numbers in it.
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrintPhoneNumbers
public PrintPhoneNumbers()
startElement
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes attrs)
throws SAXException
- When we see a "phone" element, print out the area code and phone
number
- Specified by:
startElement in interface ContentHandler- Overrides:
startElement in class DefaultHandler
- Throws:
SAXException
warning
public void warning(SAXParseException ex)
- Specified by:
warning in interface ErrorHandler- Overrides:
warning in class DefaultHandler
error
public void error(SAXParseException ex)
- Specified by:
error in interface ErrorHandler- Overrides:
error in class DefaultHandler
fatalError
public void fatalError(SAXParseException ex)
- Specified by:
fatalError in interface ErrorHandler- Overrides:
fatalError in class DefaultHandler
main
public static void main(String[] args)
- Parses an XML file using SAX with an instance of this class used
for callbacks
Copyright © 2000-2009 Portland State University. All Rights Reserved.