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...