title: Python parse XML and save as txt
body: <p>I have a folder of .xml files which look like this:</p>
  
  <pre><code>&lt;PubmedArticleSet&gt;
    &lt;PubmedArticle&gt;
      &lt;MedlineCitation Owner="NLM" Status="MEDLINE"&gt;
        &lt;PMID Version="1"&gt;23458631&lt;/PMID&gt;
        &lt;DateCreated&gt;
          &lt;Year&gt;2013&lt;/Year&gt;
          &lt;Month&gt;04&lt;/Month&gt;
          &lt;Day&gt;08&lt;/Day&gt;
        &lt;/DateCreated&gt;
        &lt;MeshHeadingList&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Animals&lt;/DescriptorName&gt;
          &lt;/MeshHeading&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Calcium&lt;/DescriptorName&gt;
            &lt;QualifierName MajorTopicYN="Y"&gt;metabolism&lt;/QualifierName&gt;
          &lt;/MeshHeading&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Calcium Chloride&lt;/DescriptorName&gt;
            &lt;QualifierName MajorTopicYN="N"&gt;administration &amp;amp; dosage&lt;/QualifierName&gt;
          &lt;/MeshHeading&gt;
        &lt;/MeshHeadingList&gt;
      &lt;/MedlineCitation&gt;
    &lt;/PubmedArticle&gt;
    &lt;PubmedArticle&gt;
      &lt;MedlineCitation Status="Publisher" Owner="NLM"&gt;
        &lt;PMID Version="1"&gt;23458629&lt;/PMID&gt;
        &lt;DateCreated&gt;
          &lt;Year&gt;2013&lt;/Year&gt;
          &lt;Month&gt;3&lt;/Month&gt;
          &lt;Day&gt;20&lt;/Day&gt;
        &lt;/DateCreated&gt;
        &lt;MeshHeadingList&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Adolescent&lt;/DescriptorName&gt;
          &lt;/MeshHeading&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Adult&lt;/DescriptorName&gt;
          &lt;/MeshHeading&gt;
          &lt;MeshHeading&gt;
            &lt;DescriptorName MajorTopicYN="N"&gt;Anthropometry&lt;/DescriptorName&gt;
          &lt;/MeshHeading&gt;
        &lt;/MeshHeadingList&gt;
      &lt;/MedlineCitation&gt;
    &lt;/PubmedArticle&gt;
  &lt;/PubmedArticleSet&gt;
  </code></pre>
  
  <p>I would like to use Python to parse the XML files and extract PMID,DateCreated,all DescriptorName and MajorTopicYN for each article. Then, save the result as .txt file that looks like:</p>
  
  <pre><code>ArticleID|CreatedDate|MeSH|IsMajor
  23458631|20130408|Animals|N
  23458631|20130408|Calcium|N
  23458631|20130408|Calcium Chloride|N
  23458629|20130320|Adolescent|N
  23458629|20130320|Adult|N
  23458629|20130320|Anthropometry|N
  </code></pre>