minidom xml attribute creation

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


Hello,

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")
                root.setAttribute("name","bug")
                self.doc.appendChild(root)              
                print self.doc.toprettyxml()


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

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

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

Any ideas?
Thanks

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





More information about the Python-list mailing list