title: Parsing XML using Python minidom
body: <pre><code> &lt;PacketHeader&gt;   
       &lt;HeaderField&gt;
          &lt;name&gt;number&lt;/name&gt;
          &lt;dataType&gt;int&lt;/dataType&gt;
       &lt;/HeaderField&gt;
   &lt;/PacketHeader&gt;
  </code></pre>
  
  <p>This is my small XML file and I want to extract out the text which is within the name tag.</p>
  
  <p>Here is my code snippet:-</p>
  
  <pre><code>from xml.dom import minidom
  from xml.dom.minidom import parse
  
  xmldoc = minidom.parse('sample.xml')
  packetHeader = xmldoc.getElementsByTagName("PacketHeader")
  headerField = packetHeader.getElementsByTagName("HeaderField")
  for field in headerField:
      getFieldName = field.getElementsByTagName("name")
      print getFieldName
  </code></pre>
  
  <p>But I am getting the location but not the text.</p>