Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:57:13+00:00 2026-06-11T23:57:13+00:00

A normal query to the Youtube gdata API for a given video like this:

  • 0

A normal query to the Youtube gdata API for a given video like this:

http://gdata.youtube.com/feeds/api/videos?q=H-x7UumBaFs

Returns a result like this:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:yt="http://gdata.youtube.com/schemas/2007">
<!-- data -->
<entry>
<!-- data -->
<gd:rating average="3.2309198" max="5" min="1" numRaters="511" rel="http://schemas.google.com/g/2005#overall"/>
</entry>
</feed>

However sometimes the gd:rating line is not present.

I would like to read the data from this line if it exists. I tried to check for this with:

if node.at_xpath(".//gd:rating/@numRaters")

But this doesn’t work, giving the error “Undefined namespace prefix: .//gd:rating/@numRaters”

Do you know how I can check for the existence of the gd:rating namespace before reading from it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:57:14+00:00Added an answer on June 11, 2026 at 11:57 pm

    Thanks to this question and the Nokogiri docs, this is the solution that worked for me:

    gd_namespace = {"xmlns:gd" => "http://schemas.google.com/g/2005"}
    
    ...
    
    s.num_raters = node.at_xpath('.//gd:rating/@numRaters', gd_namespace).try(:text)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data that, in a normal query, would appear like this: Val1 Val2
Why does this query work normal: Query query = session.createQuery(from Table tab); And this
This might be a very simple thing. Check out the normal sql query below
The normal JSON approach looks something like this: { list: [ { header1: some
A normal UserControl looks like this in XAML: <UserControl x:Class=mynamespace.foo ...namespaces...> <!-- content -->
I saw a ADO.NET EF and LINQ pagging structure like this: var query =
I'd like to create a stored procedure or a normal query with values passed
I use something like this: $url_title = mysql_real_escape_string($_GET['title']); $sql = dbquery("SELECT * FROM `videos`
I would like to know how can I query index from asp.net application. I
I have what I think to be a normal query-call in CakePHP - it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.