The class representing an XML element node.

Hierarchy (View Summary)

Accessors

  • get content(): string
  • The content string of the node.

    Returns string

  • get line(): number
  • The line number of the node if the node is parsed from an XML document.

    Returns number

  • get name(): string
  • The name of this node.

    Returns string

  • get namespacePrefix(): string
  • Alias of prefix

    Returns string

  • set namespacePrefix(prefix: string): void
  • Parameters

    • prefix: string

    Returns void

  • get namespaceUri(): string
  • The URI of the namespace applied to this node.

    Returns string

  • get nsDeclarations(): NamespaceMap
  • Namespace declarations on this element

    Returns NamespaceMap

    Empty object if there's no local namespace definition on this element. Note that default namespace uses empty string as key in the returned object.

  • get prefix(): string
  • The prefix representing the namespace applied to this node.

    Returns string

  • set prefix(prefix: string): void
  • Set the namespace prefix of this node.

    Parameters

    • prefix: string

      The new prefix to set. Use empty string to remove the prefix.

    Returns void

Methods

  • Parameters

    • uri: string
    • Optionalprefix: string

    Returns void

    use addNsDeclaration instead.

  • Add a namespace declaration to this element.

    Parameters

    • uri: string

      The namespace URI.

    • Optionalprefix: string

      The prefix that the namespace to be used as. If not provided, it will be treated as default namespace.

    Returns void

    XmlError if namespace declaration already exists.

  • Add a child text node to the end of the children list. Note that this method will merge the text node if the last child is also a text node.

    Parameters

    • text: string

      the content of the text node

    Returns XmlText

  • Get the attribute of this element.

    Parameters

    • name: string

      The name of the attribute

    • Optionalprefix: string

      The namespace prefix to the attribute.

    Returns null | XmlAttribute

    null if the attribute doesn't exist.

  • Set the attribute of this element.

    Parameters

    • name: string

      The name of the attribute

    • value: string

      The value of the attribute

    • Optionalprefix: string

      The namespace prefix to the attribute.

    Returns XmlAttribute