minidom xml attribute creation

Nate Gelbard gelbardn at
Mon Jul 28 23:08:52 CEST 2003


I have python 2.2.3 on my RH 7.2 box. When I create an XML Element and
set an attribute on that element, the name of the attribute is truncated
to one letter. On a RH 7.3 box, this error does not occur. I thought my
libexpat version was old, so I upgraded and relinked python, but this
did not help.

Here is a code example:

from xml.dom.minidom import Document

class Test:
        def __init__(self):
                self.doc = Document()

        def toXml(self):
                root = self.doc.createElement("root")
                print self.doc.toprettyxml()

if __name__ == "__main__":
        t = Test()

<?xml version="1.0" ?>
<root a="bug"/>

The output should be:
<?xml version="1.0" ?>
<root name="bug"/>

Any ideas?

--( Nate Gelbard, QA Engineer     
--( Tripwire, Inc., The Integrity Assurance Company

More information about the Python-list mailing list