Search code examples
pythonxmlxmldom

xml.dom.minidom count how many tags of a specific type exist


I'm trying to work with the wolfram alpha api and I want to get a count back of how many <plaintext></plaintext> elements there are so I can run through them with dom.getElementsByTagName


Solution

  • Just use,

    dom.getElementsByTagName("plaintext").length
    

    getElementsByTagName() returns a NodeList which has a property length.

    Documentation