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
url
A
URL
object specifying a URL. The URL must be fully qualified and refer to a scheme that is supported by theURL
type.Return Value
An initialized
Parser
object ornil
if 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
string
A
String
object containing XML markup.encoding
The encoding of the
String
object.Return Value
An initialized
Parser
object ornil
if an error occurs. -
Initializes a parser with the XML contents encapsulated in a given data object.
Declaration
Swift
public convenience init?(data: Data?)
Parameters
data
A
Data
object containing XML markup.Return Value
An initialized
Parser
object. -
Initializes a parser with the XML contents from the specified stream.
Declaration
Swift
public convenience init?(stream: InputStream)
Parameters
stream
The input stream. The content is incrementally loaded from the specified stream and parsed. The
Parser
will open the stream, and synchronously read from it without scheduling it.Return Value
An initialized
Parser
object. -
Performs the parsing operation.
Declaration
Swift
public final func parse() -> ParserResult
Return Value
The result of the parsing operation.