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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
static void
Parses an XML file using SAX with an instance of this class used for callbacksvoid
startElement
(String namespaceURI, String localName, String qName, Attributes attrs) When we see a "phone" element, print out the area code and phone numbervoid
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
Methods 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:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classDefaultHandler
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classDefaultHandler
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classDefaultHandler
-
main
Parses an XML file using SAX with an instance of this class used for callbacks
-