0
다음 문과 함께 Ruby에서 Xpath를 사용하고 있습니다.반환 된 XPath HTML에서 특정 텍스트를 일치시키는 방법은 무엇입니까?
print XPath.first(Document.new(html),"//tr[@id='ctl00_c1_rr_ci_trAdd']//td[2]")
쿼리는 다음 텍스트를 반환합니다.
<td>
1371 N Belsay Rd<br/>Burton, MI 48509
<br/>
<a href='http://www.mapquest.com/maps/map.adp?style=2&address=1371+N+Belsay+Rd&city=Burton&state=MI&zip=48509' class='rptLnk2' id='ctl00_c1_rr_ci_hlMapQuest' target='_blank'>See the location on a Mapquest Map</a>
<br/>
<a href='http://maps.google.com?q=1371+N+Belsay+Rd Burton, MI 48509' class='rptLnk2' id='ctl00_c1_rr_ci_hlGoogleMaps' target='_blank'>See the location on a Google Map</a>
</td>
하지만 난 그냥이 텍스트는
1371 N Belsay Rd<br/>Burton, MI 48509
사람이 어떻게 이것을 달성하기 위해 말해 줄 수 싶어? 스캔 문을 사용할 때 -이 오류가 발생합니다.
private method `scan' called for <td> ... </>:REXML::Element (NoMethodError)
1371 N Belsay Rd가 아니라 1371 N Belsay Rd
Burton, MI 48509' – Shubham
@Shubham : 죄송합니다. 질문을 잘 읽지 못했습니다. 내 대답을 편집하고 지금 당신이 요구하는 노드를 정확하게 선택하는 XPath식이 있습니다. –