Top

class Document

smx. Document

The Document class wraps an XMLDocument and provides an easy to use api to interact with it and its contents.

This class can be further extended by mixins from custom modules.

Constructor

new Document(xmlDocument)

Parameters
  • xmlDocument {XMLDocument}

Members

[0]:XMLDocument

  • protected

Original XMLDocument for reference

_cache:Object

  • private

Contains an id → key map of all processed nodes for easy acccess.

_data:Object

  • private

Namespace for storing custom modules data.

path:String

  • readonly

Gets Uniform Resource Locator Concatenation of path values from parent nodes up to document root

src:String

  • readonly

Gets the source file url for this document.

root:smx.Node

  • readonly

Gets the root node.

Methods

getNodeById(id) → {smx.Node}

Gets the node with the given identifier.

Parameters
  • id {String}
Returns

find(selector, [context]) → {Array.<smx.Node>}

Finds all nodes matching the given selector.

Parameters
  • selector {String} :

    search selector

  • [context] {smx.Node} :

    node context to find inside

Returns

wrap(s) → {smx.Node|Array.<smx.Node>}

Wraps an existing node or nodes in smx paradigm.

Parameters
  • s {XMLNode|Array.<XMLNode>}
Returns