0
我想从此文本blob中提取数据。此文本包含制表符分隔的文本和xml标记的文本。我想提取xml blob并为我的分析分别进行解析。从xml和制表符分隔的文本中提取数据
Text1 Text2 text3 text4 text4 <Assessment>
<Questions>
<Question>
<Id>1</Id>
<Key>Instructions</Key>
<QuestionText>Your Age</QuestionText>
<QuestionType>Label</QuestionType>
<Answer>16-30</Answer>
</Question>
</Questions>
</Assessment> text5
Text1 Text2 text3 text4 text4 <Assessment>
<Questions>
<Question>
<Id>1</Id>
<Key>Instructions</Key>
<QuestionText>Your Age</QuestionText>
<QuestionType>Label</QuestionType>
<Answer>31-49</Answer>
</Question>
</Questions>
</Assessment> text5
我已阅读文本使用readlines
并做了以下操作。
tst<-gsub("^\\s+","", tst)
idx<-which(grepl("+<Assessment>+", tst))
tst[idx]<-"<Assessment>"
idx<-which(grepl("</Assessment>", tst))
tst[idx]<-"</Assessment>"
还没有想出如何使用XML解析它。
请参见[如何做一个伟大的[R重现的问题(http://stackoverflow.com/questions/5963269 /如何对化妆一个伟大-R重现-例子)。你没有发布任何代码。你实际上是在寻求代码即服务。这不是什么意思。你有什么尝试? – hrbrmstr