i fetch one html fragment like
"<li>市 场 价"
which contains "
", but after calling to_s
of Nokogiri NodeSet, it becomes
"<li>市 场 价"
, i want to keep the original html fragment, and tried to set :save_with option
for to_s
method, but failed.
can someone encounter the same problem and give me help? thank you in advance.
I encountered a similar situation, and what I came up was a bit of a hack, but it seems to work well.
nbsp = Nokogiri::HTML(" ").text
text.gsub(nbsp, " ")
In my case, I wanted the nbsp to be a regular space. I think in your case, you want them to be returned to a " ", so you could do something like:
nbsp = Nokogiri::HTML(" ").text
html.gsub(nbsp, " ")