title: Parse floats and return paths except for certain attribute values
body: <p>I am trying to parse the floats of a deeply nested XML file and return the paths of this nodes except for certain attribute values. E.g. given the file below, I would like to return all floats but exclude certain attributes say month=05 &amp;  month=06,</p>
  
  <pre><code>&lt;data&gt;
  &lt;country name="Liechtenstein"&gt;
      &lt;rank updated="yes"&gt;2&lt;/rank&gt;
      &lt;language&gt;english&lt;/language&gt;
      &lt;currency&gt;1.21$/kg&lt;/currency&gt; 
      &lt;gdppc month="06"&gt;141100&lt;/gdppc&gt;
      &lt;gdpnp month="10"&gt;2.304e+0150&lt;/gdpnp&gt;
      &lt;neighbor name="Austria" direction="E"/&gt;
      &lt;neighbor name="Switzerland" direction="W"/&gt;
  &lt;/country&gt;
  &lt;country name="Singapore"&gt;
      &lt;rank updated="yes"&gt;5&lt;/rank&gt;
      &lt;language&gt;english&lt;/language&gt;
      &lt;currency&gt;4.1$/kg&lt;/currency&gt; 
      &lt;gdppc month="05"&gt;59900&lt;/gdppc&gt;
      &lt;gdpnp month="08"&gt;5.2e-015&lt;/gdpnp&gt;
      &lt;neighbor name="Malaysia" direction="N"/&gt;
  &lt;/country&gt;
  </code></pre>
  
  <p>I would like to return <code>2</code>, <code>2.304e+0150</code>, <code>5</code> and <code>5.2e-015</code> along with their <code>paths</code> i.e. omit texts that are not totally numeric e.g. <code>english</code>, <code>1.21$/kg</code> or <code>4.1$/kg</code>. While also restricting text from attributes <code>month=05</code> &amp;  <code>month=06</code> i.e. <code>141100</code> and <code>59900</code>.</p>
  
  <p>From the previous post I have the following which gets the path of all float-able numbers.</p>
  
  <pre><code>def extractNumbers(path, node):
      nums = []
  
      path += '/' + node.tag
      if 'name' in node.keys():
          path += '=' + node.attrib['name']
  
      try:
          num = float(node.text)
          nums.append( (path, num) )
      except (ValueError, TypeError):
          pass
  
      for e in list(node):
          nums.extend( extractNumbers(path, e) )
  
      return nums
  
  tree = ET.parse('jerry.xml')
  nums = extractNumbers('', tree.getroot())
  print len(nums)
  print nums
  </code></pre>
  
  <p>How can I add attribute restriction to this? When i add <code>node.attrib["month"] in ["05","06"]</code> to the except function, it doesnot work. I would appreciate any help.</p>