AttributeError: 'module' object has no attribute 'getElementsByTagName'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Saad Bin Ahmed
    New Member
    • Jul 2011
    • 25

    AttributeError: 'module' object has no attribute 'getElementsByTagName'

    Hey,

    I am using Ubuntu10.04 with python 2.6 on 64bit system,
    I want to run xml file but it stucks with an error as mentioned below.

    File "online_xml.py" , line 60, in readStrokes
    strokes = dom.getElements ByTagName("Stro ke")
    AttributeError: 'module' object has no attribute 'getElementsByT agName'

    Please suggest me about the possible error that may have.
    Thanks in advance.
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    I have been using xml.dom.minidom , but it should work in a similar way. Create an xml document object. getElementsByTa gName is a method of the xml document object.

    Example:
    Code:
    from xml.dom.minidom import parseString
    ...snip...
                f = open("data.xml', 'rb')
                self.doc = parseString(f.read())
                f.close()
                value = self.doc.getElementsByTagName(tag)

    Comment

    Working...