일부 html을 분석하기 위해 Nokogiri를 사용하고 있습니다. 하지만, 노드의 원시 html을 얻는 방법을 모르겠습니다. 예를 들어, 주어진 :Nokogiri가 노드의 원시 html을 얻습니다.
<tr class="tableX">
<td align="center">
<font size="2"><a href="javascript:open('9746')">9746</a></font>
</td>
<td align="center">
<font size="2">2012-06-26</font>
</td>
</tr>
나는이 XPath를 사용하는 경우 :
doc = Nokogiri::HTML(html)
nodes = doc.search("//tr[@class='tablebX']")
nodes.each do |node|
node.text # or node.content
end
node.text
및 node.content
의 결과는 다음과 같습니다
9746
2012-06-26
내가 tr
안에 모든 원시 HTML을 좀하고 싶습니다 블록. 이 경우 :
<td align="center">
<font size="2"><a href="javascript:open('9746')">9746</a></font>
</td>
<td align="center">
<font size="2">2012-06-26</font>
</td>
어떻게해야할까요?