2009-10-19 8 views

Répondre

5
doc.xpath('/html/body/a').each{ |a| a.swap("<span>#{a}</span>") } 

trouvé une meilleure solution (modifier selon @Phrogz)

doc.search('a').wrap('<span/>') 
+0

La méthode '' to_string' appelle to_xml'? – Geo

+0

'to_s' renvoie' to_xml'/'to_html',' to_str' renvoie 'text' – tig

+1

Tout aussi efficace, sans la duplication:' doc.css ('a'). Wrap ('') ' – Phrogz

Questions connexes