#!/usr/bin/env python import xml.dom.minidom XML=""" """ NS1 = "http://path/to/ns1#" NS2 = "http://path/to/ns2#" doc = xml.dom.minidom.parseString(XML).documentElement dgEBTN = doc.getElementsByTagName print dgEBTN('child1')[0].attributes.itemsNS() print dgEBTN('child2')[0].attributes.itemsNS() print dgEBTN('child3')[0].attributes.itemsNS() if dgEBTN('child1')[0].getAttributeNS(NS1, 'attr') == 'value1': print "Successfully got child1 attr value" if dgEBTN('child2')[0].getAttributeNS(NS1, 'attr') == 'value2': print "Successfully got child2 attr value" if dgEBTN('child3')[0].getAttributeNS(NS2, 'attr') == 'value3': print "Successfully got child3 attr value"