How to generate XML

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Dec 24 00:28:26 CET 2001


"Irmen de Jong" <usenet at NOSPAM-irmen.cjb.net> writes:

> 3. inconsistencies (one ducument had US-ASCII encoding, 

> I believe that all five problems above are solved by doing it this way.

I don't think you can solve problem 3 with that strategy, at least not
in the way you use the DOM.

> What would be wrong with (hypothetical code):-
>     doc=Doc("UTF-8")
>     root=Element("root",{"type","sometype"})

The element name must be a Unicode string, likewise the attribute name
and the attribute value. The DOM is defined in terms of Unicode. It is
only that Python does not have strict static typing that you get away
with this kind of error.

To properly use the DOM, use Unicode strings throughout. 

Regards,
Martin



More information about the Python-list mailing list