title: scraping nested xml using cheerio
body: <p>I'm trying to scrap some PubMed data using cheerio. The following script works ok but when some xml tag does not exist, it generates an erroneously ordered output.</p>
  
  <pre><code>var request = require('request'),
  cheerio = require('cheerio');
  request('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&amp;retmode=xml&amp;id=23545583,23103438', 
    function(error, response, body) {
      var $ = cheerio.load(body);
      for (var i = 0; i &lt; $('PubmedArticle').length; i++) {
          console.log($('PubmedArticle PMID').slice(0).eq(i).text());
          console.log($('PubmedArticle DateCreated Year').slice(0).eq(i).text());
          console.log($('PubmedArticle ArticleTitle').slice(0).eq(i).text());
          console.log($('PubmedArticle Abstract AbstractText').slice(0).eq(i).text());
        };
  });
  </code></pre>
  
  <p>In this example the abstract outputs below the first title instead second because first article does not contain abstract.</p>