only mutool run
This represents an HTML or an DOM node. It is a helper class intended to access the DOM (Document Object Model) content of a Story object.
You cannot create instances of this class with the new operator!
Instances of this class are returned by Story.prototype.document().
Return a DOM for the body element.
var result = xml.body()Return a DOM for the top level element.
var result = xml.documentElement()Create an element with the given tag type, but do not link it into the DOM yet.
string) – Tag name to use for
element.var result = xml.createElement("div")Create a text node with the given text contents, but do not link it into the DOM yet.
string) – Text contents to put
into element.var result = xml.createElement("Hello world!")Find the first element matching the tag, attribute and value. Set
either of those to null to match anything.
string) – The tag of the element
to look for.string) – The attribute of
the element to look for.string) – The value of the
attribute of the element to look for.var result = xml.find("tag", "attribute", "value")Find the next element matching the tag, attribute and value. Set
either of those to null to match anything.
string) – The tag of the element
to look for.string) – The attribute of
the element to look for.string) – The value of the
attribute of the element to look for.var result = xml.findNext("tag", "attribute", "value")Insert an element as the last child of a parent, unlinking the child from its current position if required.
xml.appendChild(dom, childDom)Insert an element before this element, unlinking the new element from its current position if required.
xml.insertBefore(dom, elementDom)Insert an element after this element, unlinking the new element from its current position if required.
xml.insertAfter(dom, elementDom)Remove this element from the DOM. The element can be added back elsewhere if required.
var result = xml.remove()Clone this element (and its children). The clone is not yet linked into the DOM.
var result = xml.clone()Return the first child of the element as a DOM, or
null if no child exist.
var result = xml.firstChild()Return the parent of the element as a DOM, or
null if no parent exists.
var result = xml.parent()Return the next element as a DOM, or null if no such element exists.
var result = xml.next()Return the previous element as a DOM, or null if no such element exists.
var result = xml.previous()Add attribute with the given value, returns the updated element as a DOM.
string) – Desired attribute
name.string) – Desired attribute
value.var result = xml.addAttribute("attribute", "value")Remove the specified attribute from the element, returns the updated element as a DOM.
string) – The name of the
attribute to remove.xml.removeAttribute("attribute")Return the element’s attribute value as a string, or null if no such attribute exists.
string) – The name of the
attribute to look up.var result = xml.attribute("attribute")Returns a dictionary object with properties and their values corresponding to the element’s attributes and their values.
var dict = xml.getAttributes()only mutool run
Returns the text contents of the node.
var text = xml.getText()only mutool run
Returns the tag name for the node.
var text = xml.getTag()