TafParser
public class TafParser : NSObject, XMLParserDelegate, XMLCustomParserProtocol
The TafParser class will parse the XML document containing TAF data and return an array of TAF objects.
This class parses the XML document in the parseDocument function and returns the array of TAF’s in a closure.
-
The variable that contains TAF XML for testing. There are three individual TAF’s used for testing.
Declaration
Swift
public var sampleTAF: String { get }
-
Initializes the new TafParser.
Declaration
Swift
public override init()Return Value
A new instance of the TafParser.
-
The completion block for the return of parsed TAF objects.
Declaration
Swift
public typealias parseCompletion = (_ taf: [Any]) -> ()Parameters
tafAn array of TAF objects parsed from the XML documents
-
This function will parse the XML document and return an array of TAF obects.
Declaration
Swift
public func parseDocument(_ data: Data, completion: parseCompletion)Parameters
dataData representation of the XML document
completionThe completion block that returns the TAF array
-
An
XMLParserDelegatefunction when the parser starts the XML document.Declaration
Swift
public func parserDidStartDocument(_ parser: XMLParser)Parameters
parserThe
XMLParserused to parse this document. -
An
XMLParserDelegatefunction when the parser ends the XML document.Declaration
Swift
public func parserDidEndDocument(_ parser: XMLParser)Parameters
parserThe
XMLParserused to parse this document. -
An
XMLParserDelegatefunction when the parser starts an element in the XML document.Declaration
Swift
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:])Parameters
parserThe
XMLParserused to parse this document.elementNameThe name of the element that is starting.
namespaceURIThe namespace for this element.
qNameThe qualified name of the element that is starting.
attributeDictA
[String:String]dictionary containing attribute names and attribute values. -
An
XMLParserDelegatefunction when the parser ends an element in the XML document.Declaration
Swift
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?)Parameters
parserThe
XMLParserused to parse this document.elementNameThe name of the element that is ending.
namespaceURIThe namespace for this element.
qNameThe qualified name of the element that is ending.
-
An
XMLParserDelegatefunction when the parser finds characters in the element of the XML document.Declaration
Swift
public func parser(_ parser: XMLParser, foundCharacters string: String)Parameters
parserThe
XMLParserused to parse this document.stringThe characters of the element.
-
An
XMLParserDelegatefunction when the parser starts the XML document.Declaration
Swift
public func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error)Parameters
parserThe
XMLParserused to parse this document.parseErrorThe
Errorthat occurred when parsing the document.
TafParser Class Reference