我怎么能把它翻译成红宝石nokogiri?

时间:2009-10-11 08:27:10

标签: jquery ruby nokogiri

$("br",top.document).parent().contents().each(function() {
    textx = this.textContent.replace(/\s+/g, '')
    if ( this.nodeType == 3 && textx.length ) {
        $(this).wrap('<div id="uniqja__' + numero  + '"></div>')
    }
})

1 个答案:

答案 0 :(得分:0)

也许是这样的?

require 'rubygems'
require 'nokogiri'

doc = Nokogiri::HTML(your_html)
top_document = doc.xpath("//path_to_an_element")

top_document.
    xpath("//*[br]/text()[string-length(normalize-space()) != 0]").
    wrap("<div id=\"uniqja__#{numero}\"></div>")