title: lapply on list of xml objects
body: <p>this is my first post here, so please forgive any mistakes wrt the posting guidelines</p>
  
  <p>I'm trying to read in xml data from pubmed, to extract data on author affiliations</p>
  
  <p>each entry contains a set of nodes like so:</p>
  
  <pre><code>&lt;AuthorList&gt;
            &lt;Author&gt;
              &lt;LastName&gt;Serra-Blasco&lt;/LastName&gt;
              &lt;ForeName&gt;Maria&lt;/ForeName&gt;
              &lt;Initials&gt;M&lt;/Initials&gt;
              &lt;AffiliationInfo&gt;
                &lt;Affiliation&gt;Department of Psychiatry, Hospital de la Santa Creu i Sant Pau, Biomedical Research Institute Sant Pau (IIB Sant Pau), Universitat AutÃ²noma de Barcelona (UAB), Centro de InvestigaciÃ³n BiomÃ©dica en Red de Salud Mental (CIBERSAM), Barcelona, Catalonia, Spain.&lt;/Affiliation&gt;
              &lt;/AffiliationInfo&gt;
            &lt;/Author&gt;
            ...
  </code></pre>
  
  <p>I would like to end up with a dataframe that contains each authors name and affiliation in a row.</p>
  
  <p>I tried to do this using xpathSApply to parse nodes reading "//Author", and ended up with a list of xml nodes.</p>
  
  <p>Further parsing is proving to be a problem: i've written code that works on an individual element of this list;</p>
  
  <p>for eg if the list is <code>authorlist</code></p>
  
  <p>I can extract an appropriate array for <code>authorlist[[1]]</code> using this function (that uses xpathSApply within the element)</p>
  
  <p>But when I try to wrap lapply around this function, it gives me an error that says that it cannot perform xpathApply on a list. The exact error call is:</p>
  
  <blockquote>
    <p>Error in UseMethod("xpathApply") :    no applicable method for
    'xpathApply' applied to an object of class "list"</p>
  </blockquote>
  
  <p>I surmise that lapply calls the list subsetting with the equivalent of [i] whereas what I need is [[i]]. Is there a way around this? Or will I have to rewrite with some other rules in mind?</p>
  
  <p>I'm open to rewriting (this is just some goofing around I'm doing) but this problem seemed interesting, hope you can help!</p>