Role Playing Database (API Documentation)  3.1.1
Public Member Functions | Static Public Member Functions | List of all members
SimpleDOMElement Class Reference

A simple DOM element coded in Tcl using SNIT. This class implements a simplified DOM element, that implements the getElementsByTagName and getElementsById methods, along with accessors to get data, attributes, and children of XML elements. More...

Public Member Functions

 SimpleDOMElement (...)
 
 ~SimpleDOMElement ()
 
 children ()
 
 replaceChildren (newchildren)
 
 addchild (childnode)
 
 length ()
 
 data ()
 
 setdata (d)
 
 appenddata (d)
 
 display (fp="stdout", indent="",...)
 
 attribute (attrname)
 
 setAttribute (attrname, value="")
 
 getElementsByTagName (thetag,...)
 
 getElementsById (theid)
 
 isChild (item)
 
 getParent (item)
 
 removeChild (item)
 

Static Public Member Functions

static validate (object)
 Validation typemethod. Raises an error if its argument is not a SimpleDOMElement object. More...
 

Detailed Description

A simple DOM element coded in Tcl using SNIT. This class implements a simplified DOM element, that implements the getElementsByTagName and getElementsById methods, along with accessors to get data, attributes, and children of XML elements.

Author
Robert Heller <heller@deepsoft.com>.

Constructor & Destructor Documentation

◆ SimpleDOMElement()

SimpleDOMElement::SimpleDOMElement (   ...)

The constructor. Just sets the options.

Parameters
objnameElement name. Generally %AUTO% is passed.
...Options:
  • -tag The element's tag.
  • -attributes The element's attributes.
  • -opts The element's options.

◆ ~SimpleDOMElement()

SimpleDOMElement::~SimpleDOMElement ( )

The destructor – free up all memory by destroying all children.

Member Function Documentation

◆ addchild()

SimpleDOMElement::addchild ( childnode  )

Method to add a child node.

Parameters
childnodeThe child node to add.

◆ appenddata()

SimpleDOMElement::appenddata ( )

Method to append to the element's data.

Parameters
dThe new data.

◆ attribute()

SimpleDOMElement::attribute ( attrname  )

Method to return a selected attribute's value.

Parameters
attrnameThe name of the attribute.
Returns
The attribute's value or the empty string.

◆ children()

SimpleDOMElement::children ( )

Method to return the element's children.

Returns
The children.

◆ data()

SimpleDOMElement::data ( )

Method to return the element's data.

Returns
The data.

◆ display()

SimpleDOMElement::display ( fp  = "stdout",
indent  = "",
  ... 
)

Method to display a node, along with its children, and a proper XML document.

Parameters
fpChannel to write the display to.
indentThe indentation to use.
...Options
  • -addnamespace Boolean (default no) Add namespace.

◆ getElementsById()

SimpleDOMElement::getElementsById ( theid  )

Method to return all of the elements under this element with the specified value of their id attribute.

Parameters
theidThe id value match.
Returns
A list of element object with the matching id value.

◆ getElementsByTagName()

SimpleDOMElement::getElementsByTagName ( thetag  ,
  ... 
)

Method to return all of the elements under this element with the specified tag name.

Parameters
thetagThe tag to match.
Returns
A list of element object with the matching tag.

◆ getParent()

SimpleDOMElement::getParent ( item  )

Method to get the parent of the item.

Parameters
itemThe item to get the parent of.
Returns
The parent node or {} if none found.

◆ isChild()

SimpleDOMElement::isChild ( item  )

Method to check if the item is a child of this node.

Parameters
itemThe possible child.
Returns
True if item is a child, false otherwise.

◆ length()

SimpleDOMElement::length ( )

Method to return the number of children.

Returns
The number of children.

◆ removeChild()

SimpleDOMElement::removeChild ( item  )

Method to remove item from the children of this node.

Parameters
itemThe item to remove.

◆ replaceChildren()

SimpleDOMElement::replaceChildren ( newchildren  )

Method to replace the element's children.

Parameters
newchildrenThe new children list.
Returns
The old children
Exceptions
Invalidtype error if elements of newchildren are not SimpleDOMElement objects.

◆ setAttribute()

SimpleDOMElement::setAttribute ( attrname  ,
value  = "" 
)

Method to set a selected attribute's value.

Parameters
attrnameThe name of the attribute.
valueThe value to set. Default is the empty string.

◆ setdata()

SimpleDOMElement::setdata ( )

Method to set the element's data.

Parameters
dThe new data.

◆ validate()

static SimpleDOMElement::validate ( object  )
static

Validation typemethod. Raises an error if its argument is not a SimpleDOMElement object.

Parameters
objectThe object to typecheck.
Returns
The object or raise an error.

The documentation for this class was generated from the following file: