Home | Trees | Index | Help |
---|
Package docutils :: Module nodes :: Class Element |
|
Node
--+
|
Element
XmlFragment
,
XpathReference
Element
is the superclass to all specific elements.
Elements contain attributes and child nodes. Elements emulate dictionaries for attributes, indexing by attribute name (a string). To set the attribute 'att' to 'value', do:
element['att'] = 'value'
There are two special attributes: 'ids' and 'names'. Both are lists of unique identifiers, and names serve as human interfaces to IDs. Names are case- and whitespace-normalized (see the fully_normalize_name() function), and IDs conform to the regular expression [a-z](-?[a-z0-9]+)* (see the make_id() function).
Elements also emulate lists for child nodes (element nodes and/or text nodes), indexing by integer. To get the first child node, use:
element[0]
Elements may be constructed using the += operator. To add one new child node to element, do:
element += node
This is equivalent to element.append(node).
To add a list of multiple child nodes at once, use the same += operator:
element += [node1, node2]
This is equivalent to element.extend([node1, node2]).
Method Summary | |
---|---|
__init__(self,
rawsource,
*children,
**attributes)
| |
__add__(self,
other)
| |
__delitem__(self,
key)
| |
__getitem__(self,
key)
| |
Append a node or a list of nodes to self.children . | |
__len__(self)
| |
__radd__(self,
other)
| |
__repr__(self)
| |
__setitem__(self,
key,
item)
| |
__str__(self)
| |
__unicode__(self)
| |
append(self,
item)
| |
astext(self)
| |
attlist(self)
| |
clear(self)
| |
Return a copy of self. | |
Return a deep copy of self (also copying children). | |
delattr(self,
attr)
| |
emptytag(self)
| |
endtag(self)
| |
extend(self,
item)
| |
Return the index of the first child whose class exactly matches. | |
Return the index of the first child whose class does not match. | |
get(self,
key,
failobj)
| |
has_key(self,
attr)
| |
hasattr(self,
attr)
| |
index(self,
item)
| |
insert(self,
index,
item)
| |
is_not_default(self,
key)
| |
non_default_attributes(self)
| |
Note that this Element has been referenced by its name name or id id . | |
Return an indented pseudo-XML representation, for test purposes. | |
pop(self,
i)
| |
remove(self,
item)
| |
Replace one child Node with another child or children. | |
Replace self node with new , where new is a node or a
list of nodes. | |
Add a new class to the "classes" attribute. | |
setdefault(self,
key,
failobj)
| |
shortrepr(self)
| |
starttag(self)
| |
Update basic attributes ('ids', 'names', 'classes', 'dupnames', but not 'source') from node or dictionary dict . | |
Inherited from Node | |
Node instances are always true, even if they're empty. | |
Return a DOM fragment representation of this Node. | |
Return the first node in the iterable returned by traverse(), or None if the iterable is empty. | |
| |
Return an iterable containing | |
Traverse a tree of Node objects, calling the
dispatch_visit() method of visitor when entering each
node. | |
Perform a tree traversal similarly to Node.walk() (which
see), except also call the dispatch_departure() method
before exiting each node. |
Class Variable Summary | |
---|---|
str |
child_text_separator = '\n\n'
|
tuple |
list_attributes = ('ids', 'classes', 'names', 'dupnames'...
|
NoneType |
tagname = None |
Inherited from Node | |
NoneType |
document = None |
NoneType |
line = None |
NoneType |
parent = None |
NoneType |
source = None |
Method Details |
---|
__iadd__(self, other)Append a node or a list of nodes to |
copy(self)Return a copy of self.
|
deepcopy(self)Return a deep copy of self (also copying children).
|
first_child_matching_class(self, childclass, start=0, end=2147483647)Return the index of the first child whose class exactly matches. Parameters:
|
first_child_not_matching_class(self, childclass, start=0, end=2147483647)Return the index of the first child whose class does not match. Parameters:
|
note_referenced_by(self, name=None, id=None)Note that this Element has been referenced by its name
|
pformat(self, indent=' ', level=0)Return an indented pseudo-XML representation, for test purposes. Override in subclasses.
|
replace(self, old, new)Replace one child |
replace_self(self, new)Replace |
set_class(self, name)Add a new class to the "classes" attribute. |
update_basic_atts(self, dict)Update basic attributes ('ids', 'names', 'classes',
'dupnames', but not 'source') from node or dictionary |
Class Variable Details |
---|
child_text_separator
|
list_attributes
|
tagname
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Wed Jul 12 11:20:41 2006 | http://epydoc.sf.net |