我有一个代码:
<div class="activityBody postBody thing">
<p>
<a href="/forum/conversation/post/3904-22" rel="post" data-id="3904-22" class="mqPostRef">(22)</a>
where?
</p>
</div>
我正在使用此代码提取文本:
html_nodes(messageNode, xpath=".//p") %>% html_text() %>% paste0(collapse="\n")
并得到结果:
"(22) where?"
但我只需要“p”文本,不包括子节点中可能位于“p”内的文本。我必须得到这个文本:
"where"
有没有办法在我获取文本时排除子节点?
Mac OS 10.11.6 (15G31)、RSrudio 版本 0.99.903、R 版本 3.3.1 (2016-06-21)