如何获取XML父属性值

我有多个声明,如:

        

blah name是某些特定值,如test7我需要相应的房间名称。 我如何实现这一目标?

我从未使用Nokogiri,但我尝试过这似乎有效:

  xml_doc.css('blah[name="test7"]').first.ancestors("Room").first['name'] => "test3" 

检查nil

 2.3.1 :132 > xml_doc.css('blah[name="test7"]').map { |node| node.ancestors("Room").first['name'] } => ["test3"]