Classes
The following classes are available globally.
-
Instances of this class parse XML documents into a tree of DOM objects.
See moreDeclaration
Swift
public class Parser
-
The
See moreDocument
class represents the entire document. Conceptually, it is the root of the document tree, and provides the primary access to the document’s data.Declaration
Swift
public final class Document: ParentNode
-
By far the vast majority of objects (apart from text) that authors encounter when traversing a document are Element nodes. Assume the following XML document:
<elementExample id="demo"> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample>
When represented using the DOM, the top node is an
Element
node forelementExample
, which contains two childElement
nodes, one forsubelement1
and one forsubelement2
.subelement1
contains no child nodes.Elements may have attributes associated with them; since the
See moreElement
class implements theNode
protocol, theattributes
property of theNode
protocol may be used to retrieve a dictionary of the attributes for an element.Declaration
Swift
public final class Element: ParentNode
-
The
See moreText
class represents the textual content (termed character data in XML) of anElement
. If there is no markup inside an element’s content, the text is contained in a single object implementing theText
protocol that is the only child of the element. If there is markup, it is parsed into a sequence of elements andText
nodes that form the array of children of the element.Declaration
Swift
public final class Text: TextNode
-
CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. The only delimiter that is recognized in a CDATA section is the
"]]>"
string that ends the CDATA section. CDATA sections can not be nested. The primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.The
See moretext
property holds the text that is contained by the CDATA section. Note that this may contain characters that need to be escaped outside of CDATA sections.Declaration
Swift
public final class CDATASection: TextNode