interface documentation

Interface to XML element nodes.

See Element for a detailed example of its general use.

Warning: this Interface is not yet complete!

Method addChild Adds a node as child of this element.
Method addContent Adds character data to this element.
Method addElement Create an element and add as child.
Method toXml Serializes object to a (partial) XML document
Attribute attributes Dictionary of element attributes
Attribute children List of child nodes
Attribute defaultUri Default namespace URI of child elements
Attribute localPrefixes Dictionary of local prefixes
Attribute name Element's local name
Attribute parent Reference to element's parent element
Attribute uri Element's namespace URI
def addChild(node): (source)

Adds a node as child of this element.

The node will be added to the list of childs of this element, and will have this element set as its parent when node provides IElement. If node is a str and the current last child is character data (str), the text from node is appended to the existing last child.

Parameters
node:str or object implementing IElementthe child node.
def addContent(text): (source)

Adds character data to this element.

If the current last child of this element is a string, the text will be appended to that string. Otherwise, the text will be added as a new child.

Parameters
text:strThe character data to be added to this element.
def addElement(name, defaultUri=None, content=None): (source)

Create an element and add as child.

The new element is added to this element as a child, and will have this element as its parent.

Parameters
name:str or tuple of (str, str)element name. This can be either a str object that contains the local name, or a tuple of (uri, local_name) for a fully qualified name. In the former case, the namespace URI is inherited from this element.
defaultUri:strdefault namespace URI for child elements. If None, this is inherited from this element.
content:strtext contained by the new element.
Returns
object providing IElementthe created element
def toXml(prefixes=None, closeElement=1, defaultUri='', prefixesInScope=None): (source)

Serializes object to a (partial) XML document

Parameters
prefixes:dictdictionary that maps namespace URIs to suggested prefix names.
closeElement:intflag that determines whether to include the closing tag of the element in the serialized string. A value of 0 only generates the element's start tag. A value of 1 yields a complete serialization.
defaultUri:strInitial default namespace URI. This is most useful for partial rendering, where the logical parent element (of which the starttag was already serialized) declares a default namespace that should be inherited.
prefixesInScope:listlist of prefixes that are assumed to be declared by ancestors.
Returns
str(partial) serialized XML
attributes = (source)

Dictionary of element attributes

children = (source)

List of child nodes

defaultUri = (source)

Default namespace URI of child elements

localPrefixes = (source)

Dictionary of local prefixes

Element's local name

Reference to element's parent element

Element's namespace URI