Add space between nodes with Nokogiri
nokogiri, ruby
Solution
You can do
doc = Nokogiri::HTML("<p>Hello</p><p>There</p>")
doc.xpath('//text()').to_a.join(" ")
Problem
I have a string of HTML where I want to strip all the html tags. The problem is that the plain text of each node is squished together and I need to add some whitespace between each node. ``` Nokogiri::HTML("<p>Hello</p><p>There</p>").text Gives => HelloThere I want => Hello There ``` Can I tell Nokogiri to behave like this somehow?