title: Read XML file in Python
body: <p>I'm using ElementTree in Python to read an XML file and get some values. The problem is that I successfully got the variable names, but I cannot read the values contained, for instance, in the TABLE tag under DEFINITION tag.</p>
  
  <p>Here's my code to read the names:</p>
  
  <pre><code>tree = parse("basicfirealarm.xml")
  root = tree.find('NETWORK')
  
  for node in root:
      var = node.find('NAME')        # access the var definition
      print var.text
  </code></pre>
  
  <p>This is the file I'm trying to read, can you give me some suggestions how I can access the values in the TABLE tag using ElementTree? </p>
  
  <p>Thank you</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="US-ASCII"?&gt;
  
  &lt;!-- DTD for the XMLBIF 0.3 format --&gt;
  &lt;!DOCTYPE BIF [
  &lt;!ELEMENT BIF ( NETWORK )*&gt;
     &lt;!ATTLIST BIF VERSION CDATA #REQUIRED&gt;
  &lt;!ELEMENT NETWORK ( NAME, ( PROPERTY | VARIABLE | DEFINITION )* )&gt;
  &lt;!ELEMENT NAME (#PCDATA)&gt;
  &lt;!ELEMENT VARIABLE ( NAME, ( OUTCOME |  PROPERTY )* ) &gt;
  &lt;!ATTLIST VARIABLE TYPE (nature|decision|utility) "nature"&gt;
  &lt;!ELEMENT OUTCOME (#PCDATA)&gt;
  &lt;!ELEMENT DEFINITION ( FOR | GIVEN | TABLE | PROPERTY )* &gt;
  &lt;!ELEMENT FOR (#PCDATA)&gt;
  &lt;!ELEMENT GIVEN (#PCDATA)&gt;
  &lt;!ELEMENT TABLE (#PCDATA)&gt;
  &lt;!ELEMENT PROPERTY (#PCDATA)&gt;
  ]&gt;
  
  &lt;BIF VERSION="0.3"&gt;
  &lt;NETWORK&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;tampering&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (-148.1863, -197.12207)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;fire&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (67.29127, -200.31433)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;alarm&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (-46.03397, -61.451008)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;smoke&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (158.27069, -67.83553)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;leaving&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (-44.437843, 74.22005)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  &lt;VARIABLE TYPE="nature"&gt;
     &lt;NAME&gt;report&lt;/NAME&gt;
     &lt;OUTCOME&gt;T&lt;/OUTCOME&gt;
     &lt;OUTCOME&gt;F&lt;/OUTCOME&gt;
     &lt;PROPERTY&gt;position = (-42.841713, 200.31433)&lt;/PROPERTY&gt;
  &lt;/VARIABLE&gt;
  
  
  &lt;DEFINITION&gt;
     &lt;FOR&gt;tampering&lt;/FOR&gt;
     &lt;TABLE&gt; 0.02 0.98&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  &lt;DEFINITION&gt;b
     &lt;FOR&gt;fire&lt;/FOR&gt;
     &lt;TABLE&gt; 0.01 0.99&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  &lt;DEFINITION&gt;
     &lt;FOR&gt;alarm&lt;/FOR&gt;
     &lt;GIVEN&gt;tampering&lt;/GIVEN&gt;
     &lt;GIVEN&gt;fire&lt;/GIVEN&gt;
     &lt;TABLE&gt; 0.5 0.5 0.85 0.15 0.99 0.01 1.0E-4 0.9999&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  &lt;DEFINITION&gt;
     &lt;FOR&gt;smoke&lt;/FOR&gt;
     &lt;GIVEN&gt;fire&lt;/GIVEN&gt;
     &lt;TABLE&gt; 0.9 0.1 0.01 0.99&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  &lt;DEFINITION&gt;
     &lt;FOR&gt;leaving&lt;/FOR&gt;
     &lt;GIVEN&gt;alarm&lt;/GIVEN&gt;
     &lt;TABLE&gt; 0.88 0.12 0.0010 0.999&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  &lt;DEFINITION&gt;
     &lt;FOR&gt;report&lt;/FOR&gt;
     &lt;GIVEN&gt;leaving&lt;/GIVEN&gt;
     &lt;TABLE&gt; 0.75 0.25 0.01 0.99&lt;/TABLE&gt;
  &lt;/DEFINITION&gt;
  
  
  &lt;/NETWORK&gt;
  &lt;/BIF&gt;
  </code></pre>