Re: [xml] Python XML doc displayer



On Fri, Dec 03, 2004 at 03:03:47PM -0500, David Turvene wrote:
I'm learning libxml2 because it seems to be robust and actively
maintained.  Also, I like the rich python support.   In one of my
learning exercises, I emulate xmlDebugDumpDocument by recursively
descending the document tree.  The program is pasted below.  I ran it
against several libxml2-2.6.16/doc/*.xml files for testing. My
comments/questions:

1) How does one get the document header properties (e.g. 'version',
'standalone', the DTD refentry) via python?

  since there is no function accessor for them at the C level
I doubt there is any bindings to access them.

2) I had a problem testing if a node has a name space.  The libxml2.py
code throws an exception when xmlNode::ns() is called and I didn't see a
test ('hasNs'?) for namespace presence.

  same thing, it's usually available directly from C by accessing
the structure. Please bugzilla it should not crash anyway

3) Is there a better way to walk the node tree?

  glancing at the code, this looks fine. I think there is a python
iterator available, but I don't remember the details.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]