title: how to get results from xml sax parser in python
body: <p>I working on xml sax parser to parse xml files and below is my code</p>
  <p><strong>xml file code:</strong></p>
  <pre><code>&lt;job&gt;
      &lt;title&gt;Registered Nurse-Epilepsy&lt;/title&gt;
      &lt;job-code&gt;881723&lt;/job-code&gt;
      &lt;detail-url&gt;http://search.careers-hcanorthtexas.com/s/Job-Details/Registered-Nurse-Epilepsy-Job/Medical-City/xjdp-cl289619-jf120-ct2181-jid4041800?s_cid=Advance
      &lt;/detail-url&gt;
      &lt;job-category&gt;Neuroscience Nursing&lt;/job-category&gt;
      &lt;description&gt;
          &lt;summary&gt;
              &lt;div class='descriptionheader'&gt;Description&lt;/div&gt;&lt;P STYLE=&quot;margin-top:0px;margin-bottom:0px&quot;&gt;&lt;SPAN STYLE=&quot;font-family:Arial;font-size:small&quot;&gt;Utilizing the standards set forth for Nursing Practice by the ANA and ONS, the RN will organize, modify, evaluate, document and maintain the plan of care for Epilepsy and/or Neurological patients. It will include individualized, family centered, holistic, supportive, and safe age-specific care.&lt;/SPAN&gt;&lt;/P&gt;&lt;div class='qualificationsheader'&gt;Qualifications&lt;/div&gt;&lt;UL STYLE=&quot;list-style-type:disc&quot;&gt; &lt;LI&gt;Graduate of an accredited school of Professional Nursing.&lt;/LI&gt; &lt;LI&gt;BSN preferred &lt;/LI&gt; &lt;LI&gt;Current licensure with the Board of Nurse Examiners for the State of Texas&lt;/LI&gt; &lt;LI&gt;Experience in Epilepsy Monitoring and/or Neurological background preferred.&lt;/LI&gt; &lt;LI&gt;ACLS preferred, within 6 months of hire&lt;/LI&gt; &lt;LI&gt;PALS required upon hire&lt;/LI&gt; &lt;/UL&gt;
         &lt;/summary&gt;
      &lt;/description&gt;
      &lt;posted-date&gt;2012-07-26&lt;/posted-date&gt;
      &lt;location&gt;
         &lt;address&gt;7777 Forest Lane&lt;/address&gt;
         &lt;city&gt;Dallas&lt;/city&gt;
         &lt;state&gt;TX&lt;/state&gt;
         &lt;zip&gt;75230&lt;/zip&gt;
         &lt;country&gt;US&lt;/country&gt;
      &lt;/location&gt;
      &lt;company&gt;
         &lt;name&gt;Medical City (Dallas, TX)&lt;/name&gt;
        &lt;url&gt;http://www.hcanorthtexas.com/careers/search-jobs.dot&lt;/url&gt;
      &lt;/company&gt;
  &lt;/job&gt; 
  </code></pre>
  <p><strong>Python code</strong>: (partial code to clear my doubt until start element function)</p>
  <pre class="lang-py prettyprint-override"><code>from xml.sax.handler import ContentHandler
  import xml.sax
  import xml.parsers.expat
  import ConfigParser
  
  class Exact(xml.sax.handler.ContentHandler):
    def __init__(self):
      self.curpath = []
  
    def startElement(self, name, attrs):
      print name,attrs
      self.clearFields()
  
  
    def endElement(self, name):
      pass
  
    def characters(self, data):
      self.buffer += data
  
    def clearFields():
      self.fields = {}
      self.fields['title'] = None
      self.fields['job-code'] = None
      self.fields['detail-url'] = None
      self.fields['job-category'] = None
      self.fields['description'] = None
      self.fields['summary'] = None
      self.fields['posted-date'] = None
      self.fields['location'] = None
      self.fields['address'] = None
      self.fields['city'] = None
      self.fields['state'] = None
      self.fields['zip'] = None
      self.fields['country'] = None
      self.fields['company'] = None
      self.fields['name'] = None
      self.fields['url'] = None
      
      self.buffer = ''
        
  if __name__ == '__main__':
    parser = xml.sax.make_parser()
    handler = Exact()
    parser.setContentHandler(handler)
    parser.parse(open('/path/to/xml_file.xml'))
  </code></pre>
  <p><strong>result</strong>:
  The result to the above print statement is given below</p>
  <pre><code>job     &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  title   &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  job-code &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  detail-url &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  job-category &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  description  &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  summary       &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  posted-date   &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  location      &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  address       &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  city          &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  state         &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  zip           &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  country       &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  company       &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  name          &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  url           &lt;xml.sax.xmlreader.AttributesImpl instance at 0x2c0ba70&gt;
  </code></pre>
  <p>As you can observe above i am getting <code>name</code> and <code>attrs</code> from the print statement, but
  now all my intention is to get value of that name, how to fetch the values for all those tags above because i am getting only node names but not values.</p>
  <p><strong>Edited Code:</strong></p>
  <p>i really confused on how to map the data from the nodes to the keys in the dictionary as stated above</p>