Book Image

Mastering Swift

By : Jon Hoffman
Book Image

Mastering Swift

By: Jon Hoffman

Overview of this book

Table of Contents (22 chapters)
Mastering Swift
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the NSXMLParserDelegate protocol


The NSXMLParserDelegate protocol defines several optional methods that can be defined by the NSXMLParser delegate. These methods are called when certain parsing events occur while NSXMLParser is parsing XML documents. The NSXMLParserDelegate method may also define several optional methods that are used to handle the Document Type Definition (DTD) markup. The DTD markup defines the legal document structure of an XML document by defining a list of valid elements and attributes.

We will be implementing the following delegate methods for the XML example of this chapter, as follows:

  • parserDidStartDocument(_:): This method is called when the parser begins parsing the XML document

  • parserDidEndDocument(_:): This method is called after the parser has successfully parsed the entire XML document

  • parser(_: didStartElement: namespaceURI: qualifiedName: attributes:): This method is called when the parser encounters a start tag for an element

  • parser(_: didEndElement: namespaceURI...