Get attribute value from XML

nokogiri, ruby

Solution

You can use the following:

xml.at('//show/@name').text

which is XPath expression that returns the `name` attribute from the `show` element.

Problem

I have this chunk of XML: ``` <show name="Are We There Yet?"> <sid>24588</sid> <network>TBS</network> <title>The Kwandanegaba Children's Fund Episode</title> <ep>03x31</ep> <link> http://www.tvrage.com/shows/id-24588/episodes/1065228407 </link> </show> ``` I am trying to get "Are we there yet?" via Nokogiri. It is effectively the 'name' attribute of 'show'. I'm struggling to figure out how to parse this. `xml.at_css('show').value` was my best guess but doesn't work.

Original source