Classes

The following classes are available globally.

  • Instances of this class parse XML documents into a tree of DOM objects.

    See more

    Declaration

    Swift

    public class Parser
  • The Document class represents the entire document. Conceptually, it is the root of the document tree, and provides the primary access to the document’s data.

    See more

    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 for elementExample, which contains two child Element nodes, one for subelement1 and one for subelement2. subelement1 contains no child nodes.

    Elements may have attributes associated with them; since the Element class implements the Node protocol, the attributes property of the Node protocol may be used to retrieve a dictionary of the attributes for an element.

    See more

    Declaration

    Swift

    public final class Element: ParentNode
  • The Text class represents the textual content (termed character data in XML) of an Element. If there is no markup inside an element’s content, the text is contained in a single object implementing the Text protocol that is the only child of the element. If there is markup, it is parsed into a sequence of elements and Text nodes that form the array of children of the element.

    See more

    Declaration

    Swift

    public final class Text: TextNode
  • The ProcessingInstruction class represents a processing instruction, used in XML as a way to keep processor-secific information in the text of the document.

    See more

    Declaration

    Swift

    public final class ProcessingInstruction: LeafNode
  • This represents the content of a comment, i.e., all the characters between the starting <!-- and ending -->.

    See more

    Declaration

    Swift

    public final class Comment: 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 text 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.

    See more

    Declaration

    Swift

    public final class CDATASection: TextNode