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 8266101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:02:19+00:00 2026-06-08T05:02:19+00:00

Can someone help me out real quick, im writing something that is using the

  • 0

Can someone help me out real quick, im writing something that is using the Youtube API and it gives me results in XML, i am trying to get a title of the vid from the XML response.

Here is a link to the XML : https://gdata.youtube.com/feeds/api/videos/T7sIiqq66rk?v=2

Here is my code:

string nameURL = "https://gdata.youtube.com/feeds/api/videos/" + videoID + "?v=2";
WebRequest nameRequest = WebRequest.Create(nameURL);
HttpWebResponse nameResponse = (HttpWebResponse)nameRequest.GetResponse();
Stream nameStream = nameResponse.GetResponseStream();
StreamReader nameReader = new StreamReader(nameStream);
string XML = nameReader.ReadToEnd();
var VideoInfo = from e in XElement.Parse(XML).Elements("entry") select new {Id = e.Element("title").Value};
Console.WriteLine(VideoInfo.FirstOrDefault().Id);

The debugger seems to be breaking on the WriteLine method, saying its null, i have tried some other ways as well but cants seem to get just the title element.

Edit: There is something wrong that’s causing the the results to be null, i have established that, but could someone point out why it keeps returning null.

  • 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-08T05:02:21+00:00Added an answer on June 8, 2026 at 5:02 am

    First of all, VideoInfo.FirstOrDefault() will return null if there are no entries, so it will throw an exception when you try to access the Id field.

    Since entry is the root element, you should access XDocument.Root, and not Elements("entry")

    Your code should be more like this:

    var xDoc = XDocument.Parse(XML);
    
    var VideoInfo = new {Id = xDoc.Root.Element("id").Value };
    
    Console.WriteLine(VideoInfo.Id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question hopefully someone can help out here. I'm trying to copy and paste
Perhaps someone can help me out with this one: I'm using a basic search
I am hoping someone can help me out with a quick question I have
Can someone help me out with something. I'm trying to get the current part
Can someone help me out with this one. I have a page, in which
Can someone help me figuring out why the following jQuery code doesn't work? I
can someone please help me out? I'm trying to create an input dynamically with
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
Can someone please help me figure out a way to achieve the following (see
Hope someone can help me out with this problem I am having. I just

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.