Skip to content

XMLNode

do- edited this page Dec 12, 2021 · 37 revisions

XMLNode is the SAXEvent descendant connected to XMLReader internals.

This is not an attempt to implement the W3C specification directly. XMLNode instances may or may not be parts of more complex structures similar to DOM Document.

Application code must not construct instances of this class directly. XMLReader (and, thus, SAXEventEmitter) produces XMLNodes instead of raw SAXEvents.

Members

Name Type Description
src string XML source of the opening tag, from < to >
parent XMLNode Element node parent to this one, null for root element
level int 0 for root element, parent.level + 1 otherwise
children null or [XMLNode] Array of XMLNodes, for which this one is the parent

Computed Properties

Name Type Description
type SAXEvent.TYPES.* StartElement or EndElement. XMLReader emits both, children may be available on EndElement
name string Raw element name (maybe with a namespace prefix)
localName string local name (same as name unless a namespace is set)
namespaceURI string URI of the namespace of this node, or null
attributes null or AttributesMap Attributes of this node
namespacesMap NamespacesMap Set of namespace declarations for this node
xml string Same as src, except for EndElement: empty string for self enclosing tags, </${name}> otherwise
isSelfEnclosed Boolean true iif the src's penultimate character is /
isStartElement Boolean type === 'StartElement'
isEndElement Boolean type === 'EndElement'
isCharacters Boolean type === 'Characters'

Global functions

Name, parameters Type Description
XMLNode.getLocalName (name) string Part of name after :, or the whole name unless it contains :.

Clone this wiki locally