creating XML elements
Gerhard Haering
gerhard.haering at gmx.de
Wed Jul 3 12:21:38 EDT 2002
Somebody claiming to be named "so very tired" wrote:
> Hi,
> I've been using python for parsing XML, but I need to now create and add
> elements with subelements, attributes and text. How do I do this using
> the DOM libraries assuming I just have an XML document with a root node?
Here's an example: http://www.cs.fhm.edu/~ifw00065/VitaminP/addressbook.py
These are the key lines:
doc = implementation.createDocument(None, None, None)
addressbook = doc.createElement(xmlconstants.AddressBook)
doc.appendChild(addressbook)
The rest is pretty obvious.
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list