Using Nokogiri HTML Builder to create fragment with multiple root nodes
问题 Well I have a simple problem with Nokogiri. I want to make Nokogiri::HTML::Builder to make an HTML fragment of the following form: <div> #Some stuff in here </div> <div> #Some other stuff in here </div> When trying to do: @builder = Nokogiri::HTML::Builder.new(:encoding => 'UTF-8') do |doc| doc.div { doc.p "first test" } doc.div { doc.p "second test" } end @builder.to_html I get an error: Document has already a root node , which I partly understand. I know I am not wrapping the whole thing