Package edu.pdx.cs410J.xml
Class PrintPhoneNumbers
java.lang.Object
org.xml.sax.helpers.DefaultHandler
edu.pdx.cs410J.xml.PrintPhoneNumbers
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
This program demonstrates the SAX parsing API by parsing a
phonebook XML document and printing out the phone numbers in it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidstatic voidParses an XML file using SAX with an instance of this class used for callbacksvoidstartElement(String namespaceURI, String localName, String qName, Attributes attrs) When we see a "phone" element, print out the area code and phone numbervoidMethods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
PrintPhoneNumbers
public PrintPhoneNumbers()
-
-
Method Details
-
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:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler
-
main
Parses an XML file using SAX with an instance of this class used for callbacks
-