title: Reading data from an XML File Using R
body: <p>From reading through, then trying a few previous examples on StackOverflow related to reading an XML file in R, it seems that due to the “jagged” nature of the following file I can’t use XPath related methods.</p>
  
  <p><a href="https://www.dropbox.com/s/jz8sj2fifuobkva/Data.xml?oref=e&amp;n=305307914" rel="nofollow">https://www.dropbox.com/s/jz8sj2fifuobkva/Data.xml?oref=e&amp;n=305307914</a></p>
  
  <p>Therefore, it seems I need to use a combination of xmlToList() and ldply() to read data from the following file. </p>
  
  <p>Specifically, for all 20 events in the file (ie. event.1, event.2, … event.20), I am wanting to get the following variables (structured as)</p>
  
  <ul>
  <li><code>$movements$movement$clips$clip$data$event$begin</code> (vector)</li>
  <li><code>$movements$movement$clips$clip$data$event$end</code> (vector)</li>
  <li><code>$movements$movement$clips$clip$data$event$max$cells</code> (data frame)</li>
  <li>As per above but <code>$rollover$data$quant$cells</code> where there are several samples within an event (n data frames)</li>
  </ul>
  
  <p>Based on other StackOverflow examples the code (using R v3.1.2) I have tried to read the “begin” data is as follows :- </p>
  
  <pre><code>library(XML)
  library(plyr)
  
  datfile &lt;- "D:/Data.xml"
  xmlfile &lt;- xmlTreeParse(datfile,useInternal = TRUE)
  sampledata &lt;- xmlToList(xmlfile)
  startdata &lt;- ldply(sampledata$movements$movement$clips$clip$data$event$begin)
  </code></pre>
  
  <p>When I do this I only get the first variable (0.240) in event.1. I have now got to the point where I am stuck, and have exhausted my investigations on how to do this.</p>