Role Playing Database (API Documentation) 3.1.3

Public Member Functions | Static Public Member Functions | List of all members
SimpleDOMElement Class Reference
TclCommon

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

  objname | Element 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

  childnode | The child node to add.

## ◆ appenddata()

SimpleDOMElement::appenddata | ( | d |  | ) |

Method to append to the element's data.

Parameters

  d | The new data.

## ◆ attribute()

SimpleDOMElement::attribute | ( | attrname |  | ) |

Method to return a selected attribute's value.

Parameters

  attrname | The 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

  fp | Channel to write the display to.
  indent | The 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

  theid | The 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

  thetag | The 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

  item | The 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

  item | The 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

  item | The item to remove.

## ◆ replaceChildren()

SimpleDOMElement::replaceChildren | ( | newchildren |  | ) |

Method to replace the element's children.

Parameters

  newchildren | The new children list.

Returns
  The old children

Exceptions

  Invalid | type error if elements of newchildren are not SimpleDOMElement objects.

## ◆ setAttribute()

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

Method to set a selected attribute's value.

Parameters

  attrname | The name of the attribute.
  value | The value to set. Default is the empty string.

## ◆ setdata()

SimpleDOMElement::setdata | ( | d |  | ) |

Method to set the element's data.

Parameters

  d | The new data.

## ◆ validate()

static SimpleDOMElement::validate | ( | object |  | ) |
| static

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

Parameters

  object | The object to typecheck.

Returns
  The object or raise an error.

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

- ParseXML.tcl