Nokogiri and Css Selectors with Namespaces

I’ve been using the css function from nokogiri to navigate xml and grab elements, instead of using xpath.  I love the fact that it’s an option, since css feels to much more natural.  But, today I ran into something I haven’t had to deal with before.  I was parsing some xml from a service when I noticed the xml had some namespaced items, like so.

<blah:item1>some text</blah:item1>
<blah:item2>more stuff</blah:item2>

So, I tried this, thinking I could get the value back.


But, no luck. However, as it turns out, there is a special selector made just for this. Here is the reference on The correct code is below: