【发布时间】:2012-07-06 17:52:59
【问题描述】:
我在循环中有这个 Xpath 查询,
//div[@class='listing_content'][#{i}]/div/div/h3/a/text()
我想单独处理每个节点
问题是它给出了正确的节点,但同时所有节点都一次完成。
还有i > 1的时候什么都不返回?
for i in (1...30)
name = page.xpath("//div[@class='listing_content'][#{i}]/div/div/h3/a/text()")
puts "this is name"
puts name
#Get Business phone
phone = page.xpath("//div[@class='listing_content'][#{i}]//span[@class='business-phone phone']/text()")
puts "this is phone"
puts phone
#Get Business website(if any)
puts "this is website"
website = page.xpath("//div[@class='listing_content'][#{i}]//li[@class='website-feature']//@href")
puts website
end
【问题讨论】:
-
您能发布您正在使用的标记吗?
-
原谅我的无知什么是标记?
-
提示:XML 代表什么?