Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'nokogiri'
- html = Nokogiri::HTML(DATA)
- html.xpath('//table').each do |htable|
- tbody = Nokogiri::XML::Node.new('tbody', html)
- htable.children.each do |child|
- child.parent = tbody
- end
- htable.add_child(tbody)
- end
- puts html.xpath('//table').to_s
- __END__
- <table border="0" cellspacing="5" cellpadding="5">
- <tr><td>Data</td></tr>
- <tr><td>Data2</td></tr>
- <tr><td>Data3</td></tr>
- </table>
Add Comment
Please, Sign In to add comment