Options
All
  • Public
  • Public/Protected
  • All
Menu

Class XmlNode

Represents an XML node.

This class is the root class of the XML node hierarchy. It should not be directly instantiated; one of its subclasses should be used instead.

Hierarchy

Index

Constructors

constructor

  • Initializes a new instance of the XmlNode class.

    Returns XmlNode

Properties

Protected _children

_children: XmlNode[]

Private Optional _parent

_parent: XmlNode

Accessors

parent

  • get parent(): XmlNode | undefined
  • Gets the parent of this node.

    Returns XmlNode | undefined

    The parent of this node.

Methods

children

  • Gets this node's children.

    Throws an exception if this node cannot have any children. Consult the appropriate subclass documentation for more details.

    Returns XmlNode[]

    This node's children.

insertChild

  • Inserts the specified node into this node's children at the specified index. The node is not inserted if it is already present. If this node already has a parent, it is removed from that parent.

    Throws an exception if this node cannot have any children, or if the specified node cannot be added at the specified index. Consult the appropriate subclass documentation for more details.

    Parameters

    • node: XmlNode

      The node to insert.

    • Default value index: number = this._children.length

      The index at which to insert the node. Nodes at or after the index are shifted to the right. If no index is specified, the node is inserted at the end.

    Returns XmlNode | undefined

    The node inserted into this node's children, or undefined if no node was inserted.

next

  • Gets the node that follows this one, or undefined if no such node exists or if this node has no parent.

    Returns XmlNode | undefined

    The node that follows this one, or undefined if no such node exists or if this node has no parent.

prev

  • Gets the node that is previous to this one, or undefined if no such node exists or if this node has no parent.

    Returns XmlNode | undefined

    The node that is previous to this one, or undefined if no such node exists or if this node has no parent.

remove

  • Removes this node from its parent if this node has a parent.

    Returns XmlNode | undefined

    This node's parent, or undefined if it has no parent.

removeChild

  • removeChild(node: XmlNode): boolean
  • Removes the specified node from this node's children.

    Throws an exception if this node cannot have any children, or if the specified node cannot be removed. Consult the appropriate subclass documentation for more details.

    Parameters

    • node: XmlNode

      The node to remove.

    Returns boolean

    Whether a node was removed.

removeChildAtIndex

  • removeChildAtIndex(index: number): XmlNode
  • Removes the node at the specified index from this node's children.

    Throws an exception if this node cannot have any children, or if the node at the specified index cannot be removed. Consult the appropriate subclass documentation for more details.

    Parameters

    • index: number

      The index at which the node to be removed is located.

    Returns XmlNode

    The node that was removed.

toString

  • Returns an XML string representation of this node.

    Parameters

    • Default value options: IStringOptions = {}

      Formatting options for the string representation.

    Returns string

    An XML string representation of this node.

top

  • Returns the root node of the current hierarchy. If this node has no parent, this node itself is returned.

    Returns XmlNode

    The root node of the current hierarchy.

up

  • Gets the parent of this node.

    Returns XmlNode | undefined

Generated using TypeDoc