Simple Objects from XML - quick-and-dirty XML parsing without a DOM
This module implements most of the overhead needed for turning SAX
events into a hierarchy of objects. E.g., stack handling,
delegation to node classes, etc.
If all you need is to read an XML file and turn it into objects, you
came to the right place. If you need an actual model of the XML file
that you can manipulate, with absolute fidelity to the original, you
might be better off with a DOM, since this doesn't retain processing
instructions or comments.
SOX is faster than minidom or any other DOM that I know of. On the
other hand, SOX is slower than PyRXP, but SOX handles Unicode correctly.
To use this module, you will need a "document" object that implements
either ISOXNode or ISOXNode_NS , depending on whether you want
namespace support. The interfaces are very similar, except that
the NS version has some enhancements/simplifications that can't be
added to the non-namespace version for backward-compatibility reasons.
Once you have your document object, just call
SOX.load(filenameOrStream,documentObject,namespaces=flag) to get back
the result of your document object's _finish() method after it has
absorbed all of the XML data supplied.
If you need a simple document or node class, Document , Document_NS ,
Node , and Node_NS are available for subclassing or idea-stealing.
Imported modules
|
|
from kjbuckets import kjGraph
from protocols import Interface, advise
from xml.sax import ContentHandler, parse
from xml.sax.saxutils import XMLGenerator
|
Functions
|
|
load
|
|
load
|
load (
filename_or_stream,
documentObject=None,
namespaces=False,
)
Build a tree from a filename/stream, rooted in a document object
|
Classes
|
|
|
|