Options
All
  • Public
  • Public/Protected
  • All
Menu

Class XmlAttribute

Represents an XML element attribute.

An XML element attribute is part of the start tag of an element and is structured as follows, where {name} is the name of the attribute and {value} is the value of the attribute:

<element {name}="{value}">

The {name} value is a property of this node, while the {value} property consists of the children of this node.

XmlAttribute nodes must have at least one child, and can have an unlimited number of XmlCharRef, XmlEntityRef, and XmlText nodes as children.

Hierarchy

Index

Constructors

constructor

Properties

Protected _children

_children: XmlNode[]

Private _name

_name: string

Accessors

name

  • get name(): string
  • set name(name: string): void
  • Gets the name of this attribute.

    Returns string

    The name of this attribute.

  • Sets the name of this attribute.

    Parameters

    • name: string

      The name of this attribute.

    Returns void

    The name of this attribute.

parent

  • Gets the parent of this node.

    Returns XmlNode

    The parent of this node.

Methods

charRef

  • charRef(char: string, hex: boolean, index?: number): XmlCharRef
  • Inserts a new XML character reference at the specified index.

    Parameters

    • char: string

      The character to represent using the reference.

    • hex: boolean
    • Optional index: number

    Returns XmlCharRef

    The newly created XML declaration.

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.

entityRef

  • Inserts a new XML entity reference at the specified index.

    Parameters

    • entity: string

      The entity to be referenced.

    • Optional index: number

    Returns XmlEntityRef

    The newly created XML declaration.

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.

    Note that only XmlCharRef, XmlEntityRef, and XmlText nodes can be inserted; otherwise, an exception will be thrown.

    Parameters

    • node: XmlNode

      The node to insert.

    • Optional index: number

    Returns XmlNode

    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

    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

    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

    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.

    Note that this node must have at least one child. Attempts to remove the last child node will result in an exception.

    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.

    Note that this node must have at least one child. Attempts to remove the last child node will result in an exception.

    Parameters

    • index: number

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

    Returns XmlNode

    The node that was removed, or undefined if no node was removed.

text

  • text(text: string, index?: number): XmlText
  • Inserts a new XML text node at the specified index.

    Parameters

    • text: string

      Arbitrary character data.

    • Optional index: number

    Returns XmlText

    The newly created XML declaration.

toString

  • Returns an XML string representation of this node.

    Parameters

    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

    The parent of this node.

Generated using TypeDoc