tags:

views:

81

answers:

1

given an xpath say

can you do something like

doc.xpath("/html/body/a").wrap("<span></span>")

and wrap all the links with span tags ?

+1  A: 
doc.xpath("/html/body/a").each{ |a| a.swap("<span>#{a}</span>") }

found better solution

doc.search("a").wrap('<span></span>')
tig
The `to_string` method calls `to_xml` ?
Geo
`to_s` returns `to_xml`/`to_html`, `to_str` returns `text`
tig