'Convert an XML string into a nice instance tree of XMLNodes.
xmlStr -- the XML to parse
storeXML -- if True, stores the XML string in the root XMLNode.xml'

def parseXML(cls, xmlStr, storeXML=False):

    def __parseXMLElement(element, thisNode):
        'Recursive    call    to    process    this    XMLNode.'
        thisNode.elementName = element.nodeName
        for i in range(element.attributes.length):
            an = element.attributes.item(i)
            thisNode[an.name] = an.nodeValue
        for a in element.childNodes:
            if (a.nodeType == xml.dom.Node.ELEMENT_NODE):
                child = XMLNode()
                try:
                    list = getattr(thisNode, a.nodeName)
                except AttributeError:
                    setattr(thisNode, a.nodeName, [])
                list = getattr(thisNode, a.nodeName)
                list.append(child)
                __parseXMLElement(a, child)
            elif (a.nodeType == xml.dom.Node.TEXT_NODE):
                thisNode.elementText += a.nodeValue
        return thisNode
    dom = xml.dom.minidom.parseString(xmlStr)
    rootNode = XMLNode()
    if storeXML:
        rootNode.xml = xmlStr
    return __parseXMLElement(dom.firstChild, rootNode)
