Upon running my code on a different machine, I encountered the following issue: Error: ruby: symbol lookup error: /usr/local/ruby/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.7.2/lib/nokogiri/nokogiri.so: undefined symbol: xmlNextElementSibling
At the start of the process, a warning appeared: WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.6.30 As I am unable to update nokogiri at this moment, I delved into the source code only to discover that the issue lies with the next_element method used by Nokogiri, which functions correctly on my machine but fails on the other. Therefore, my query is how can I efficiently select the next HTML element (specifically, the next "tr" in a table)?
This is the current code snippet I am utilizing:
def get_weight(spot)
frame = spot.at_css("table[id='1']").css("tr")[1]
starter = frame.at('tr:contains("D7r5")')
return nil if starter == nil
starter = starter.next_element
peso = []
until starter.css("td")[1].nil?
data = starter.css("td")[1].inner_html.gsub(/\t{0..100}/, "").strip
ndecimal = data.scan(/[0-9]{1,4},?.?[0-9]{0,3}/).last.gsub(",", ".")
nmeasure = data.scan(/[kK][Gg]|\s[g]\s|[g]/).last
case nmeasure
when (/[kK][Gg]/)
peso << ndecimal.to_f
when (/g|\s[g]\s|[g]/)
peso << ndecimal.to_f / 1000
end
starter.next_element.nil? ? break : starter = starter.next_element
end
return peso.max == 0 ? nil : peso.max
end