Known implementations: twisted.words.xish.domish.Element

Interface to XML element nodes.

See Element for a detailed example of its general use.

Warning: this Interface is not yet complete!

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

Element's namespace URI

name =

Element's local name

defaultUri =

Default namespace URI of child elements

attributes =

Dictionary of element attributes

children =

List of child nodes

parent =

Reference to element's parent element

localPrefixes =

Dictionary of local prefixes

def toXml(prefixes=None, closeElement=1, defaultUri='', prefixesInScope=None):

Serializes object to a (partial) XML document

Parametersprefixesdictionary that maps namespace URIs to suggested prefix names. (type: dict)
closeElementflag 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. (type: int)
defaultUriInitial 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. (type: unicode)
prefixesInScopelist of prefixes that are assumed to be declared by ancestors. (type: list)
Returns(partial) serialized XML (type: unicode)
def addElement(name, defaultUri=None, content=None):

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.

Parametersnameelement name. This can be either a unicode 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. (type: unicode or tuple of (unicode, unicode))
defaultUridefault namespace URI for child elements. If None, this is inherited from this element. (type: unicode)
contenttext contained by the new element. (type: unicode)
Returnsthe created element (type: object providing IElement)
def addChild(node):

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 unicode and the current last child is character data (unicode), the text from node is appended to the existing last child.

Parametersnodethe child node. (type: unicode or object implementing IElement)
def addContent(text):

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.

ParameterstextThe character data to be added to this element. (type: unicode)
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.