0
h3
태그 뒤에 한 줄의 텍스트를 추가하려고합니다. 다른 태그 또는 문서 유형Nokogiri를 사용하여 div 다음에 텍스트를 추가하는 방법
<h3>hi</h3>
:
내 시작 HTML이있다. 나는 나의 끝 HTML은 다음과 같이 할 :
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