如何在R中获取XML节点的内容?

时间:2015-03-22 23:56:16

标签: xml r

我有一个愚蠢的问题要问:如何在R中获取XML节点的内容?例如,在代码中:

<p attribute="blabla">this is what I need</p>

我需要只使用字符串&#34来获取变量;这就是我需要的#34;。为了帮助您,我精确地使用XMLNodeSet解析了网页代码。

比你提前!

1 个答案:

答案 0 :(得分:1)

E.g。使用XML包:

library(XML)
doc <- htmlParse('<p attribute="blabla">this is what I need</p>', asText = TRUE)
xmlValue(doc[["/html/body/p/text()"]]  )
# [1] "this is what I need"