将XML文档导入R时出错

时间:2016-05-31 22:21:03

标签: r xml import

我正在尝试导入XML文档并将其转换为R中的dataframe。通常以下代码可以正常工作:

xmlfile <- xmlTreeParse(file.choose()) ; topxml <- xmlRoot(xmlfile) ;  
topxml2 <- xmlSApply(topxml, function(x) xmlSApply(x, xmlValue))
psycinfo <- data.frame(t(topxml2), row.names=NULL, stringsAsFactors=FALSE) 

然而,当我尝试这个时,我得到一个dataframe,其中包含一行和22570列(这是理想情况下需要的行数,以便每条记录都有自己的多列行。< / p>

我附上了前两个记录的XML数据的片段,它应该在不同的行上。

<records>
<rec resultID="1">
      <header shortDbName="psyh" longDbName="PsycINFO" uiTerm="2016-10230-001">
        <controlInfo>
          <bkinfo>
            <btl>Reducing conservativeness of stabilization conditions for switched ts fuzzy systems.</btl>
            <aug />
          </bkinfo>
          <chapinfo />
          <revinfo />
          <jinfo>
            <jtl>Neurocomputing: An International Journal</jtl>
            <issn type="Print">09252312</issn>
          </jinfo>
          <pubinfo>
            <dt year="2016" month="02" day="16">20160216</dt>
          </pubinfo>
          <artinfo>
            <ui type="doi">10.1016/j.neucom.2016.01.067</ui>
            <tig>
              <atl>Reducing conservativeness of stabilization conditions for switched ts fuzzy systems.</atl>
            </tig>
            <aug>
              <au>Jaballi, Ahmed</au>
              <au>Hajjaji, Ahmed El</au>
              <au>Sakly, Anis</au>
            </aug>
            <sug>
              <subj type="unclass">No terms assigned</subj>
            </sug>
            <ab>In this paper, less conservative sufficient conditions for the existence of switching laws for stabilizing switched TS fuzzy systems via a fuzzy Lyapunov function (FLF) and estimates the basin of attraction are proposed. The conditions are found by exploring properties of the membership functions and are formulated in terms of linear matrix inequalities (LMIs), which can be solved very efficiently using the convex optimization techniques. Finally, the effectiveness and the reduced conservatism of the proposed results are shown through two numerical examples. (PsycINFO Database Record (c) 2016 APA, all rights reserved)</ab>
            <pubtype>Journal</pubtype>
            <pubtype>Peer Reviewed Journal</pubtype>
          </artinfo>
          <language>English</language>
        </controlInfo>
        <displayInfo>
          <pLink>
            <url>http://search.ebscohost.com/login.aspx?direct=true&amp;db=psyh&amp;AN=2016-10230-001&amp;site=ehost-live&amp;scope=site</url>
          </pLink>
        </displayInfo>
      </header>
    </rec>
    <rec resultID="2">
      <header shortDbName="psyh" longDbName="PsycINFO" uiTerm="2016-08643-001">
        <controlInfo>
          <bkinfo>
            <btl>Self–other relations in biodiversity conservation in the community: Representational processes and adjustment to new actions.</btl>
            <aug />
          </bkinfo>
          <chapinfo />
          <revinfo />
          <jinfo>
            <jtl>Journal of Community &amp; Applied Social Psychology</jtl>
            <issn type="Print">10529284</issn>
            <issn type="Electronic">10991298</issn>
          </jinfo>
          <pubinfo>
            <dt year="2016" month="02" day="15">20160215</dt>
          </pubinfo>
          <artinfo>
            <ui type="doi">10.1002/casp.2267</ui>
            <tig>
              <atl>Self–other relations in biodiversity conservation in the community: Representational processes and adjustment to new actions.</atl>
            </tig>
            <aug>
              <au>Mouro, Carla</au>
              <au>Castro, Paula</au>
            </aug>
            <sug>
              <subj type="unclass">No terms assigned</subj>
            </sug>
            <ab>This research explores the simultaneous role of two Self–Other relations in the elaboration of representations at the micro†and ontogenetic levels, assuming that it can result in acceptance and/or resistance to new laws. Drawing on the Theory of Social Representations, it concretely looks at how individuals elaborate new representations relevant for biodiversity conservation in the context of their relations with their local community (an interactional Other) and with the legal/reified sphere (an institutional Other). This is explored in two studies in Portuguese Natura 2000 sites where a conservation project calls residents to protect an atâ€risk species. Study 1 shows that (i) agreement with the institutional Other (the laws) and metaâ€representations of the interactional Other (the community) as approving of conservation independently help explain (at the ontogenetic level) internalisation of conservation goals and willingness to act; (ii) the same metaâ€representations operating at the microâ€genetic level attenuate the negative relation between ambivalence and willingness to act. Study 2 shows that a metaâ€representation of the interactional Other as showing no clear position regarding conservation increases ambivalence. Findings demonstrate the necessarily social nature of representational processes and the importance of considering them at more than one level for understanding responses to new policy/legal proposals. Copyright © 2016 John Wiley &amp; Sons, Ltd. (PsycINFO Database Record (c) 2016 APA, all rights reserved)</ab>
            <pubtype>Journal</pubtype>
            <pubtype>Peer Reviewed Journal</pubtype>
          </artinfo>
          <language>English</language>
        </controlInfo>
        <displayInfo>
          <pLink>
            <url>http://search.ebscohost.com/login.aspx?direct=true&amp;db=psyh&amp;AN=2016-08643-001&amp;site=ehost-live&amp;scope=site</url>
          </pLink>
        </displayInfo>
      </header>
    </rec>

0 个答案:

没有答案