1
이의 내가이 샘플 있다고 가정 해 봅시다 :노코 기리 부모 텍스트가 아닌 차일 텍스트를 얻을 부모로 다시 텍스트를 참조하는 방법을
page = "<html><body><h1 class='foo'></h1><p class='foo'>hello people<a href='http://'>hello world</a></p></body></html>"
@nodes = []
Nokogiri::HTML(page).traverse do |n|
if n[:class] == "foo"
@nodes << {:name => n.name, :xpath => n.path, :text => n.text }
end
end
결과가 n.text
가 hello peoplehello world
을 것 것이기를, 내가 원하는 방법으로 그것을 할 것은 그래서 부모 텍스트와 차일 텍스트를 얻을 수 있지만, 자신의 태그
에게 관련 될 수 있으므로 결과가 될이
@nodes[0][:text]=""
@node[1][:text]= [{:Elementtext1 => "hello people", :ElementObject1 => elementObject},{:Elementtext2 => "hello world", :ElementObject2 => elementObject}]
많은 감사 애드리안 – Waheedi