import libxml2 d = libxml2.parseDoc("") for n in d.xpathEval("//namespace::*"): print n d.freeDoc()