Python XML Tools
The Python XML Tools collection is built on top of PyXML and features two GTK widgets: XmlTree and XmlEditor. The Python XML Tools are available from http://www.logilab.org/xmltools/. These packages are used to display XML files (XmlTree), as well as edit them (XmlEditor).
XmlTree displays XML files in a tree-like form, familiar to those who’ve used file browsers on Windows, KDE, or GNOME. This structure takes the form of a GTK widget—it’s derived from the GtkCTree Widget.
The API features several methods for setting the XML document for display, setting XPath filters for the tree, and a class for generating metadata about the tree.
In addition to API methods, the tree features configurable key
bindings. For example, pressing an asterisk (*) recursively expands the selected node,
while the / key closes them.
The XmlEditor is also a GTK widget, but XmlEditor allows for the editing of XML documents. It uses the aforementioned XmlTree for display. The structure available for editing is currently centered around a DTD, but may change to use schema at a later date.
In addition to a simple API for driving the editor, the XmlEditor
also features an add_change_listener
method that allows you to supply a callback function. The callback
function is then executed whenever the Apply or Ok
buttons are pressed on the editor.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access