On Thu, Nov 13, 2008 at 05:44:50PM +0900, Dingding Ye wrote:
> hi.
> 
> Is nested search supported?
> 
> For example,
> 
> xml =
> "<root><body><subbody>subbody1</subbody></body><body><subbody>subbody2</subbody></body></root>"
> doc.xpath("//body").each do |body|
>   puts body.at("subbody").content
> end
> 
> I expected to see
> 
> subbody1
> subbody2
> 
> but seems it always use the root element.

Yes.  Try using an xpath search as such:

  xml =
  "<root><body><subbody>subbody1</subbody></body><body><subbody>subbody2</subbody></body></root>"
  
  Nokogiri::XML(xml).xpath("//body").each do |body|
    puts body.at(".//subbody").content
  end

-- 
Aaron Patterson
http://tenderlovemaking.com/