0
h3
タグの後にテキストの行を追加しようとしています。いいえ他のタグ、またはドキュメントタイプとNokogiriを使用してdivの後にテキストを追加する方法
<h3>hi</h3>
:
マイ開始HTMLはこれです。私は私のHTMLは次のように見て終了します:
<h3>hi</h3>
{% include 'tester-credit-button' %}
私は次のことを試してみました:
page = Nokogiri::HTML::DocumentFragment.parse("my_page.html")
title = page.at_css("h3")
#tried this first
title.children.after("\n{% include 'tester-credit-button' %}")
#then this
title << "\n{% include 'tester-credit-button' %}"
#then this
title.after("\n{% include 'tester-credit-button' %}")
#then this
text_node = Nokogiri::XML::Text.new("\n{% include 'tester-credit-button' %}"
, page)
title.add_child(text_node)
HTML、ノード、またはノードセットの構造とは関係ありません。しかし、それを提案していただきありがとうございます。 – ToddT