title: Python: How to search an xml file for a list of elements then print them
body: <p>I have an xml file that I need to parse. It is below: It is called "fttk.xml"</p>
  
  <pre><code>&lt;root&gt;
      &lt;ls&gt;
          this is the ls 
      &lt;a&gt;
          this is the ls -a 
      &lt;/a&gt;
      &lt;l&gt;
          this is the ls -l 
      &lt;/l&gt;
      &lt;/ls&gt;
      &lt;dd&gt;
          this is the dd 
          &lt;a&gt;
          this is the dd -a 
          &lt;/a&gt;
          &lt;l&gt;
          this is the dd -l 
          &lt;/l&gt;
      &lt;/dd&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Fairly simple. I want to be able to print out the text in either "ls" or "dd" tags. Then print out the tags underneath them, if specified.</p>
  
  <p>So far I've managed to be able to find the "ls" or "dd" tag in the XML and print out the text within the tag. I've done this with this code:</p>
  
  <pre><code>import xml.etree.ElementTree as ET
  
  command = "ls"
  
  fttkXML = ET.parse('fttk.xml') #parse the xml file into an elementtree
  findCommand = fttkXML.find(command) #find the command in the elementtree
  if findCommand != None:
      print (findCommand.text) #prints that tag's text
  </code></pre>
  
  <p>With that, I've saved off everything between "ls"..."/ls" tags. Now I want to search for the two flags ("a" and "l") beneath them, if specified, and print them. The tags are provided by a list like so:</p>
  
  <pre><code>switches = ["a", "l"]
  </code></pre>
  
  <p>However, I've tried to find something in ElementTree that will allow me to search for these tags from a list and print them out separately, however, the 'find' and 'findall' commands for an ElementTree or Element, returns "uhashable type list" when I attempt to feed it the 'switches' list.</p>
  
  <p>So, how would I search for a list of tags and have the text printed out for each tag?</p>
  
  <p>Thank you for your time.</p>
  
  <p>Best Regards,
  J</p>