What is wrong in my pulldom.startElement()?

Bill Xu bill.xu at newlix.com
Tue Feb 13 20:40:33 CET 2001


Hi, Gang:

Will u please tell me how to use the pulldom.startElement() in the Python
XML DOM?
 Following is my simple test program and result.
 Will u please tell me how to correct this bug?
"AttributeError: 'None' object has no attribute 'createElement'";

Thanks in advance!

Bill

=====================================================
#!/usr/bin/python
#

import os, sys, string, StringIO
import xml.dom
from xml.dom import minidom
from xml.dom.pulldom import PullDOM
import traceback



# Save the new message
def test_meth():
  print "Am i here"
  builder = PullDOM()
  builder.startElement("SET", {"PATH" : "a path"})
  builder.endElement("SET")
  print "Am i here"
  confirm(builder)
 #result = self.Print(builder)

def confirm(test, testname = "Test"):
    if test:
        print "Passed " + testname
    else:
        print "Failed " + testname
        raise Exception

print "? am i herer"
test_meth()

=======================================================
Output:

? am i herer
Am i here
Traceback (innermost last):
  File "./testdom.py", line 34, in ?
    test_meth()
  File "./testdom.py", line 20, in test_meth
    builder.startElement("SET", {"PATH" : "a path"})
  File "/usr/lib/python1.5/site-packages/xml/dom/pulldom.py", line 85, in
startElement
    node = self.document.createElement(name)
AttributeError: 'None' object has no attribute 'createElement'





More information about the Python-list mailing list