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...
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>.
◆ 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.
◆ 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
-
◆ 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
-
- 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
-
- 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
-
- 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
-
◆ replaceChildren()
SimpleDOMElement::replaceChildren |
( |
newchildren |
| ) |
|
Method to replace the element's children.
- Parameters
-
newchildren | The new children list. |
- Returns
- The old children
- Exceptions
-
◆ 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
-
◆ 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: