title: Display the contents of an element in xml using python
body: <p>etree to display my xml file, and works great for displaying the attributes of a particular element, but now I need to display the contents of an element.</p>
  
  <p>Input xml</p>
  
  <pre><code>&lt;root&gt;
      &lt;Module&gt;
          &lt;register  name="i_cmd_reg" offset="0x004" width="20" access="R/W" &gt;
              &lt;field name="value" default="0" bit_span="20"&gt;
                  &lt;description&gt;System gradient driver current command - 1.72mA/LSB&lt;/description&gt;
              &lt;/field&gt;
          &lt;/register&gt;
  
          &lt;register name="i_ecc_cmd_reg" offset="0x008" width="20" access="R/W" &gt;
              &lt;description&gt;Calculated ECC current command - 1.72mA/LSB&lt;/description&gt;
              &lt;field name="field1"/&gt;
          &lt;/register&gt;
  
      &lt;/Module&gt;       
  &lt;/root&gt;
  </code></pre>
  
  <p>Python code</p>
  
  <pre><code>from lxml import etree
  
  xml_file = etree.parse('file1.xml')
  
  
  input_1=open("sample_template.txt","r")
  output=open("output.txt","w+")
  
  i=0
  k=0
  for node in input_file.iter():
      if node.tag=="register":
          register[i]['name']=node.attrib.get("name")
          register[i]['offset']=node.attrib.get("offset")
  
          k=0
          for child_node in node:
              if child_node.tag=="field":
                  register[i]['fields'][k]['name']=child_node.attrib.get("name")
                  register[i]['fields'][k]['offset']=child_node.attrib.get("offset")
                  k+=1
  </code></pre>
  
  <p>My question is how can I store the contents of the description element, in a say a string variable? I just need to access the data in the description element.</p>
  
  <p>like
      name=child_node.tag("description")</p>
  
  <p>Thanks!</p>