如何获取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"]