Package twisted :: Package xish :: Module domish :: Class Element |
[frames | no frames]

## Class Element

    object --+
             |
            Element

Known Subclasses:
  `IQ`

Object representing a container (a.k.a. tag or element) in an HTML or XML document.

An Element contains a series of attributes (name/value pairs), content (character data), and other child Element objects. When building a document with markup (such as HTML or XML), use this object as the starting point.

Method Summary
| ``__init__`(self, qname, defaultUri, attribs)`
| `__delitem__(self, key)`
| `__getattr__(self, key)`
| `__getitem__(self, key)`
| `__setitem__(self, key, value)`
| ``__str__`(self)` Retrieve the first CData (content) node
| ``_dqa`(self, attr)` Dequalify an attribute key as needed
| ``addChild`(self, node)` Add a child to this Element
| ``addContent`(self, text)` Add some text data to this element
| ``addElement`(self, name, defaultUri, content)` Add a new child Element to this Element; preferred method
| ``addRawXml`(self, rawxmlstring)` Add a pre-serialized chunk o' XML as a child of this Element.
| ``addUniqueId`(self)` Add a unique (across a given Python session) id attribute to this Element
| ``compareAttribute`(self, attrib, value)` Safely compare the value of an attribute against a provided value; None-safe.
| ``elements`(self)` Iterate across all children of this Element that are Elements
| `firstChildElement(self)`
| ``getAttribute`(self, attribname, default)` Retrieve the value of attribname, if it exists
| ``hasAttribute`(self, attrib)` Determine if the specified attribute exists
| ``swapAttributeValues`(self, left, right)` Swap the values of two attribute
| ``toXml`(self, prefixes, closeElement)` Serialize this Element and all children to a string
Inherited from object
| `__delattr__(...)`
| `__getattribute__(...)`
| `__hash__(...)`
| `__reduce__(...)`
| `__repr__(...)`
| `__setattr__(...)`
Inherited from type
| `__new__(...)`

Instance Variable Summary
`dict` | `attributes`: Dictionary of attributes associated with this Element.
`list` | `children`: List of child Elements and content
`str` | `defaultUri`: URI this Element exists within
`str` | `name`: Name of this Element
`Element` | `parent`: Reference to the parent Element, if any.
`str` | `uri`: URI of this Element's name

Class Variable Summary
`int` | `_idCounter` = 0

Method Details

### __init__(self, qname, defaultUri=None, attribs=None) (Constructor) Parameters: `qname` - Tuple of (uri, name) `defaultUri` - The default URI of the element; defaults to the URI specified in `qname` `attribs` - Dictionary of attributes Overrides: `__builtin__.object.__init__`

### __str__(self) (Informal representation operator) Retrieve the first CData (content) node Overrides: `__builtin__.object.__str__`

### _dqa(self, attr) Dequalify an attribute key as needed

### addChild(self, node) Add a child to this Element

### addContent(self, text) Add some text data to this element

### addElement(self, name, defaultUri=None, content=None) Add a new child Element to this Element; preferred method

### addRawXml(self, rawxmlstring) Add a pre-serialized chunk o' XML as a child of this Element.

### addUniqueId(self) Add a unique (across a given Python session) id attribute to this Element

### compareAttribute(self, attrib, value) Safely compare the value of an attribute against a provided value; None-safe.

### elements(self) Iterate across all children of this Element that are Elements

### getAttribute(self, attribname, default=None) Retrieve the value of attribname, if it exists

### hasAttribute(self, attrib) Determine if the specified attribute exists

### swapAttributeValues(self, left, right) Swap the values of two attribute

### toXml(self, prefixes=None, closeElement=1) Serialize this Element and all children to a string

Instance Variable Details

### attributes Dictionary of attributes associated with this Element. Type: `dict`

### children List of child Elements and content Type: `list`

### defaultUri URI this Element exists within Type: `str`

### name Name of this Element Type: `str`

### parent Reference to the parent Element, if any. Type: `Element`

### uri URI of this Element's name Type: `str`

Class Variable Details

    ### _idCounter Type: `int` Value:
        0

Generated by Epydoc 2.0 on Sat Oct 25 00:55:08 2003 | http://epydoc.sf.net