开发者

How to extract text from a node but not from its children

I'm trying to parse this fragment with nokogiri from a page(so named a var) that contains

...
<dd>
    <a href="http://www.bo.es">Access </a>
    - 19/07/11
</dd>
...

page.at("dd").text shows me the whole text, not only dd's but also it's descendants text too. I mean

"Access - 19/07/11"
开发者_如何学运维

How can I extract only "- 19/07/11"?

(this is only an example)


Try page.xpath("//dd/text()").text

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜