GPXParser
public final class GPXParser : NSObject
extension GPXParser: XMLParserDelegate
An event-driven parser (SAX parser), currently parses GPX v1.1 files only.
This parser is already setted up, hence, does not require any handling, and will parse files directly as objects.
To get the parsed data from a GPX file, simply initialize the parser, and get the GPXRoot from parsedData().
-
for parsing with
DatatypeDeclaration
Swift
public init(withData data: Data)Parameters
dataThe input must be
Dataobject containing GPX markup data, and should not benil -
for parsing with
InputStreamtypeDeclaration
Swift
public init(withStream stream: InputStream)Parameters
streamThe input must be a input stream allowing GPX markup data to be parsed synchronously
-
for parsing with
URLtypeDeclaration
Swift
public init?(withURL url: URL)Parameters
urlThe input must be a
URL, which should point to a GPX file located at the URL given -
for parsing with a string that contains full GPX markup
Declaration
Swift
public convenience init?(withRawString string: String?)Parameters
stringThe input
Stringmust contain full GPX markup, which is typically contained in a.GPXfile -
for parsing with a path to a GPX file
Declaration
Swift
public convenience init?(withPath path: String)Parameters
pathThe input path, with type
String, must contain a path that points to a GPX file used to facilitate parsing.
-
Starts parsing, returns parsed
GPXRootwhen done.Throws
GPXErrorerrors if an incident has occurred while midway or after parsing the GPX file.Declaration
Swift
public func fallibleParsedData(forceContinue: Bool) throws -> GPXRoot?Parameters
forceContinueIf
true, parser will continue parsing even if non XML-based issues like invalid coordinates have occurred -
Starts parsing, returns parsed
GPXRootwhen done.Declaration
Swift
public func legacyParsingData() -> GPXLegacyRoot? -
Default XML Parser Delegate’s start element (
) callback. Declaration
Swift
public func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) -
Default XML Parser Delegate callback when characters are found.
Declaration
Swift
public func parser(_ parser: XMLParser, foundCharacters string: String) -
Default XML Parser Delegate’s end element () callback.
Declaration
Swift
public func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) -
Handling of XML parser’s thrown error. (if there is any)
Declaration
Swift
public func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) -
Parse GPX file, while lossy compressing it straight away, post-parsing.
Great for basic direct compression needs.
Declaration
Swift
public func lossyParsing(type: GPXCompression.lossyTypes, affecting types: [GPXCompression.lossyOptions]) -> GPXRoot?
View on GitHub
GPXParser Class Reference