Find and replace entire HTML nodes with Nokogiri

前端 未结 1 977
我寻月下人不归
我寻月下人不归 2020-12-31 08:34

i have an HTML, that should be transformed, having some tags replaced with another tags.

I don\'t know about these tags, because they will come from db. So, se

相关标签:
1条回答
  • 2020-12-31 09:12

    Like that:

    doc.css("div.to-replace").each do |div|
        new_node = doc.create_element "span"
        new_node.inner_html = self.get_html_text
        div.replace new_node
    end
    
    0 讨论(0)
提交回复
热议问题