nokogiri: how to insert tbody tag immediately after table tag ?

Posted by wefwgeweg on Stack Overflow See other posts from Stack Overflow or by wefwgeweg
Published on 2010-04-21T05:14:19Z Indexed on 2010/04/24 5:53 UTC
Read the original article Hit count: 323

Filed under:

i want to make sure all table's immediate child is tbody....

how can i write this with xpath or nokogiri ?

 doc.search("//table/").each do |j|
  new_parent = Nokogiri::XML::Node.new('tbody',doc)
  j.replace  new_parent
  new_parent << j
 end

© Stack Overflow or respective owner

Related posts about nokogiri