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

    taf

    An 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

    data

    Data representation of the XML document

    completion

    The completion block that returns the TAF array

  • An XMLParserDelegate function when the parser starts the XML document.

    Declaration

    Swift

    public func parserDidStartDocument(_ parser: XMLParser)

    Parameters

    parser

    The XMLParser used to parse this document.

  • An XMLParserDelegate function when the parser ends the XML document.

    Declaration

    Swift

    public func parserDidEndDocument(_ parser: XMLParser)

    Parameters

    parser

    The XMLParser used to parse this document.

  • An XMLParserDelegate function 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

    parser

    The XMLParser used to parse this document.

    elementName

    The name of the element that is starting.

    namespaceURI

    The namespace for this element.

    qName

    The qualified name of the element that is starting.

    attributeDict

    A [String:String] dictionary containing attribute names and attribute values.

  • An XMLParserDelegate function 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

    parser

    The XMLParser used to parse this document.

    elementName

    The name of the element that is ending.

    namespaceURI

    The namespace for this element.

    qName

    The qualified name of the element that is ending.

  • An XMLParserDelegate function when the parser finds characters in the element of the XML document.

    Declaration

    Swift

    public func parser(_ parser: XMLParser, foundCharacters string: String)

    Parameters

    parser

    The XMLParser used to parse this document.

    string

    The characters of the element.

  • An XMLParserDelegate function when the parser starts the XML document.

    Declaration

    Swift

    public func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error)

    Parameters

    parser

    The XMLParser used to parse this document.

    parseError

    The Error that occurred when parsing the document.