Parser
public class Parser
Instances of this class parse XML documents into a tree of DOM objects.
-
Used to represent a parser error.
See moreDeclaration
Swift
public enum Error: Swift.Error -
Initializes a parser with the XML content referenced by the given URL.
Declaration
Swift
public convenience init?(contentsOf url: URL)Parameters
urlA
URLobject specifying a URL. The URL must be fully qualified and refer to a scheme that is supported by theURLtype.Return Value
An initialized
Parserobject ornilif an error occurs. -
Initializes a parser with the XML contents encapsulated in a given string object.
Declaration
Swift
public convenience init?(string: String, encoding: String.Encoding = .utf8)Parameters
stringA
Stringobject containing XML markup.encodingThe encoding of the
Stringobject.Return Value
An initialized
Parserobject ornilif an error occurs. -
Initializes a parser with the XML contents encapsulated in a given data object.
Declaration
Swift
public convenience init?(data: Data?)Parameters
dataA
Dataobject containing XML markup.Return Value
An initialized
Parserobject. -
Initializes a parser with the XML contents from the specified stream.
Declaration
Swift
public convenience init?(stream: InputStream)Parameters
streamThe input stream. The content is incrementally loaded from the specified stream and parsed. The
Parserwill open the stream, and synchronously read from it without scheduling it.Return Value
An initialized
Parserobject. -
Performs the parsing operation.
Declaration
Swift
public final func parse() -> ParserResultReturn Value
The result of the parsing operation.
View on GitHub
Install in Dash
Parser Class Reference