title: Python XML parsing with ElementTree: How to find values of elements with the same name?
body: <p>Disclaimer: I am new to Python, XML, and programming in general. The code (that I stole from the internet) works but has some problems that I can't seem to find the answer to or wrap my brain around...</p>
  
  <p>I am trying to parse XML files from the <a href="http://www.grants.gov/web/grants/xml-extract.html" rel="nofollow">grants.gov xml extract website</a> with the goal of removing all of the grants that are not in the "unrestricted" eligibility category (Tagged in the XML with an "EligibilityCategory" of "99".) and outputting a new xml file.</p>
  
  <p>The code I have below properly removes the funding opps of no interest but also removes funding opps that have multiple EligibilityCategorys which also include a "99". I assume this is because .find only grabs the first occurrence moves on. I tried to use .findall but couldn't work it out. Thanks in advance for any help.</p>
  
  <pre><code>import xml.etree.ElementTree as etree
  tree = etree.parse('sample.xml')
  root = tree.getroot()
  
  for FundingOppSynopsis in root.findall('FundingOppSynopsis'): 
      ID = int(FundingOppSynopsis.find('EligibilityCategory').text)
      if ID != 99:
          root.remove(FundingOppSynopsis)
  
  tree.write("Output/output.xml", xml_declaration=True, encoding='UTF-8', method="xml")
  </code></pre>
  
  <p>Sample (significantly shaved down) XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE Grants SYSTEM "http://apply07.grants.gov/search/dtd/XMLExtract.dtd"&gt;
  &lt;Grants&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;USDA-RMA-RME-2008-03&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDate&gt;03242008&lt;/ApplicationsDueDate&gt;
          &lt;Office&gt;Risk Management Agency&lt;/Office&gt;
          &lt;Agency&gt;Department of Agriculture&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;25&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;NPS-ARRAWHIS100315&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDate&gt;11282009&lt;/ApplicationsDueDate&gt;
          &lt;Office&gt;National Park Service&lt;/Office&gt;
          &lt;Agency&gt;Department of the Interior&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;00&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;OFDA-FY08-002-APS&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDate&gt;10102008&lt;/ApplicationsDueDate&gt;
          &lt;Office&gt;None&lt;/Office&gt;
          &lt;Agency&gt;Agency for International Development&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;99&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;AK-NOI08-0004&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDate&gt;07142008&lt;/ApplicationsDueDate&gt;
          &lt;Office&gt;Bureau of Land Management&lt;/Office&gt;
          &lt;Agency&gt;Department of the Interior&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;99&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;RD-RBP-BIOMASS-2007-FULL&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDate&gt;11162007&lt;/ApplicationsDueDate&gt;
          &lt;Office&gt;Business and Cooperative Programs&lt;/Office&gt;
          &lt;Agency&gt;Department of Agriculture&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;06&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;12&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;13&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;20&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;22&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;23&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;25&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
      &lt;FundingOppSynopsis&gt;
          &lt;FundingOppNumber&gt;BAA07-10&lt;/FundingOppNumber&gt;
          &lt;ApplicationsDueDateExplanation&gt;The due dates and times established for the receipt of White Papers and Full Proposals are as indicated in Section IV, Paragraph 3 of the BAA. &lt;/ApplicationsDueDateExplanation&gt;
          &lt;Office&gt;Office of Procurement Operations - Grants Division&lt;/Office&gt;
          &lt;Agency&gt;Department of Homeland Security&lt;/Agency&gt;
          &lt;EligibilityCategory&gt;00&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;01&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;02&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;04&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;05&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;06&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;07&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;08&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;11&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;12&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;13&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;20&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;21&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;22&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;23&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;25&lt;/EligibilityCategory&gt;
          &lt;EligibilityCategory&gt;99&lt;/EligibilityCategory&gt;
      &lt;/FundingOppSynopsis&gt;
  &lt;/Grants&gt;
  </code></pre>