Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get minidom to ignore namespaces?

Tags:

python

xml

I am using minidom in Python and I'd like getElementsByTagName() to match elements purely by tag-name and ignore any namespaces. The documents are being parsed by minidom.parseString(). Is it possible?

like image 320
DavidG Avatar asked Mar 27 '10 10:03

DavidG


1 Answers

getElementsByTagName does match elements purely by tagName.

Do you mean you want to match purely on localName? ie. the part of the tag name after the : (if any)? If so use the DOM Level 2 Core method getElementsByTagNameNS:

els= document.getElementsByTagNameNS('*', 'tag')
like image 91
bobince Avatar answered Oct 10 '22 23:10

bobince