orig_set_content_handler = parser.setContentHandler
parser.setContentHandler = set_content_handler
dom = minidom.parseString(doc, parser)
pos = dom.firstChild.parse_position
print("Parent: '{0}' at {1}:{2}".format(dom.firstChild.localName, pos[0],
    pos[1]))
for child in dom.firstChild.childNodes:
    if child.localName is None:
        continue
pos = child.parse_position
print("Child: '{0}' at {1}:{2}".format(child.localName, pos[0], pos[1]))
python reporting line/column of origin of XML node