marcel massana
marcel massana

Reputation: 367

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)

Upvotes: 2

Views: 371

Answers (1)

ezkl
ezkl

Reputation: 3851

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

Upvotes: 2

Related Questions