Package xmpp :: Module simplexml :: Class NodeBuilder

[hide private]
[frames] | no frames]

# Class NodeBuilder

source code
Builds a Node class minidom from data parsed to it. This class used for two purposes:

1. Creation an XML Node from a textual representation. F.e. reading a config file. See an XML2Node method.
2. Handling an incoming XML stream. This is done by mangling the __dispatch_depth parameter and redefining the dispatch method.

You do not need to use this class directly if you do not designing your own XML handler.

Instance Methods | [hide private]

__init__(self, data=None, initial_node=None) Takes two optional parameters: "data" and "initial_node". | source code

destroy(self) Method used to allow class instance to be garbage-collected. | source code

starttag(self, tag, attrs) XML Parser callback. | source code

endtag(self, tag) XML Parser callback. | source code

handle_data(self, data) XML Parser callback. | source code

handle_namespace_start(self, prefix, uri) XML Parser callback. | source code

DEBUG(self, level, text, comment=None) Gets all NodeBuilder walking events. | source code

getDom(self) Returns just built Node. | source code

dispatch(self, stanza) Gets called when the NodeBuilder reaches some level of depth on it's way up with the built node as argument. | source code

stream_header_received(self, ns, tag, attrs) Method called when stream just opened. | source code

stream_footer_received(self) Method called when stream just closed. | source code

Method Details | [hide private]

### __init__(self, data=None, initial_node=None)
(Constructor)

source code

Takes two optional parameters: "data" and "initial_node". By default class initialised with empty Node class instance. Though, if "initial_node" is provided it used as "starting point". You can think about it as of "node upgrade". "data" (if provided) feeded to parser immidiatedly after instance init.

### starttag(self, tag, attrs)

source code

XML Parser callback. Used internally

### endtag(self, tag)

source code

XML Parser callback. Used internally

### handle_data(self, data)

source code

XML Parser callback. Used internally

### handle_namespace_start(self, prefix, uri)

source code

XML Parser callback. Used internally

### DEBUG(self, level, text, comment=None)

source code

Gets all NodeBuilder walking events. Can be used for debugging if redefined.

### dispatch(self, stanza)

source code

Gets called when the NodeBuilder reaches some level of depth on it's way up with the built node as argument. Can be redefined to convert incoming XML stanzas to program events.