Options
All
  • Public
  • Public/Protected
  • All
Menu

Class XmlElement<Parent>

Represents an XML element.

A sample element is structured as follows, where {name} is the name of the element:

<{name} attname="attvalue">
    <subelem/>
    <?pitarget picontent?>
    text
</{name}></pre>

XML elements can have an unlimited number of attributes, CDATA sections, character references, comments, elements, entity references, processing instructions, and character data.

An element with no content will be represented using an empty element tag:

<{name}/>

Type parameters

  • Parent

Hierarchy

  • XmlElement

Index

Constructors

constructor

Properties

Private _attributeNames

_attributeNames: string[]

Private _children

_children: Array<Child<Parent>>

Private _name

_name: string

Private _parent

_parent: Parent

Private _replaceInvalidCharsInName

_replaceInvalidCharsInName: boolean

Private _useSelfClosingTagIfEmpty

_useSelfClosingTagIfEmpty: boolean

Private _validation

_validation: boolean

Accessors

name

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

    Returns string

  • Sets the name of this element.

    Parameters

    • name: string

    Returns void

Methods

Private allSameLineNodes

  • allSameLineNodes(nodes: Array<Child<Parent>>): boolean
  • Returns true if the specified nodes are all character references, entity references, or character data.

    Parameters

    • nodes: Array<Child<Parent>>

    Returns boolean

attribute

  • Adds an attribute to this element and returns the new attribute.

    Parameters

    Returns XmlAttribute<this>

cdata

  • Adds a CDATA section to this element and returns the new CDATA section.

    Parameters

    Returns XmlCdata<this>

charData

  • Adds character data to this element and returns the new character data.

    Parameters

    Returns XmlCharData<this>

charRef

  • Adds a character reference to this element and returns the new character reference.

    Parameters

    Returns XmlCharRef<this>

comment

  • Adds a comment to this element and returns the new comment.

    Parameters

    Returns XmlComment<this>

element

  • Adds an element to this element and returns the new element.

    Parameters

    Returns XmlElement<this>

entityRef

  • Adds an entity reference to this element and returns the new entity reference.

    Parameters

    Returns XmlEntityRef<this>

Private onSameLine

  • onSameLine(prev: Child<Parent>, next?: Child<Parent>): boolean
  • Returns true if the specified nodes are all character references, entity references, or character data.

    Parameters

    • prev: Child<Parent>
    • Optional next: Child<Parent>

    Returns boolean

procInst

  • Adds a processing instruction to this element and returns the new processing instruction.

    Parameters

    Returns XmlProcInst<this>

toString

  • Returns an XML string representation of this element using the specified options.

    Parameters

    Returns string

Private toStringWithIndent

  • Returns an XML string representation of this element using the specified options and initial indent.

    Parameters

    Returns string

up

  • up(): Parent
  • Returns the parent of this element.

    Returns Parent

Generated using TypeDoc