Undefined namespace prefix in Nokogiri and XPath
Posted
by
???? ???????
on Stack Overflow
See other posts from Stack Overflow
or by ???? ???????
Published on 2012-09-18T02:59:50Z
Indexed on
2012/09/18
3:37 UTC
Read the original article
Hit count: 191
I am trying to parse Youtube Gdata to see if video with given id exists. But there isn't normal tag but with namespace. On the link http://gdata.youtube.com/feeds/api/videos?q=KgfdlZuVz7I there is tag:
<openSearch:totalResults>1</openSearch:totalResults>
There is namespace openSearch:
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
but I dont know how to deal with it in Nokogiri and Ruby.
Here is part of code:
xmlfeed = Nokogiri::HTML(open("http://gdata.youtube.com/feeds/api/videos?q=#{video_id}"))
xmlfeed.at_xpath("openSearch:totalResults")
It gives error:
Undefined namespace prefix: openSearch:totalResults
© Stack Overflow or respective owner