XML with Python - supposed to be simple? ;)

Vladimir Cherepanov vovka_foreverREMOVE_THIS at hotmail.com
Sun Jul 21 17:17:38 EDT 2002


"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m3it38lsxm.fsf at mira.informatik.hu-berlin.de...
> "Vladimir Cherepanov" <vovka_foreverREMOVE_THIS at hotmail.com> writes:
>
> > As a complete newbie to both XML and Python, I've been trying to
> > create (any!) XML document using DOM API in PyXML package. Very
> > simple task isn't it?
>
> No, XML is difficult; it becomes more difficult the closer you get to
> it.
>
> Creating documents with DOM is indeed tricky. I recommend that you use
> plain print statements, like
>
> print "<foo/>"

Well, creating XML document wasn't my ultimate goal - in that case, C
runtime and "fprintf()" would do nicely ;), and I wouldn't be needing such
heavy machinery as Python and DOM. What I was trying to do was the
following:

1. Start learning DOM with the most basic problem.
2. Get some coding experience with Python.

I skimmed through some w3c documentation on DOM, but didn't find anything
about creating documents, apart from the statement that "it's
implementation-specific" (why?!). Most w3c documentation concerns more
advanced topics like XML parsing, etc.

> You'll then learn that you can create
> Document instances by invoking createDocument on the
> DOMImplementation. For minidom, you get the DOM implementation by
> calling xml.dom.minidom.getDOMImplementation().

Thanks, I'll try this. Btw, I didn't find this method in DOMImplementation
Interface - the only method I found was "hasFeature()".
And what about serializing?




More information about the Python-list mailing list