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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:48:13+00:00 2026-05-13T06:48:13+00:00

I realize this is a repost but I needed to as I can’t use

  • 0

I realize this is a repost but I needed to as I can’t use LINQ, ( requested in my previous post).

I need to read the woeid from the XML doc below. I need to read and store the data into a string variable so I can query the yahoo weather service.

XML returned by query:

<query yahoo:count="1"
       yahoo:created="2009-12-22T08:30:31Z"
       yahoo:lang="en-US"
       yahoo:updated="2009-12-22T08:30:31Z"
       yahoo:uri="http://query.yahooapis.com/v1/yql?q=select+woeid+from+geo.places+where+text%3D%22farnborough%2C+greater+london%2Cuk%22">

<diagnostics>
<publiclyCallable>true</publiclyCallable>

<url execution-time="32">
http://where.yahooapis.com/v1/places.q(farnborough%2C%20greater%20london%2Cuk);start=0;count=10
</url>
<user-time>33</user-time>
<service-time>32</service-time>
<build-version>4265</build-version>
</diagnostics>

<results>

<place>
<woeid>19941</woeid>
</place>
</results>
</query>

Can someone suggest how I could do this through XPath or another way which is compatible with the libraries in .net 2.0?

Thanks for the answers. As such I am using the method below, but I get an exception thrown when loading the XML document:

private string getWOEID(string UserLocation, string UserCountry)
{
    string woeID = "";

    if (UserLocation == "farnborough") { UserLocation = "farnborough" + "%2C" + "hampshire"; }

    String reqUrl = "http://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%3D%22" + UserLocation + "%2C" + UserCountry + "%22&format=xml";

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(reqUrl);
   string woeid = doc.SelectSingleNode("query/results/place/woeid/text()").Value;
    return woeID;


}
  • 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-05-13T06:48:14+00:00Added an answer on May 13, 2026 at 6:48 am

    I’ll have another go at this, using ChaosPandion’s post as a starting point:

        XmlDocument doc = new XmlDocument();
        using (XmlTextReader tr = new XmlTextReader(new StringReader(xmlString)))
        {
            tr.Namespaces = false;
            doc.Load(tr);
        }
        string woeId = doc.GetElementsByTagName("woeid")[0].InnerText;
    

    Notice here that I’m deliberately ignoring namespaces here since you don’t need them for what you are trying to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this would violate convention, but I'm curious to know if you can
I realize this is syntactically bad but I figure it somewhat explains what I'm
I realize this is more of a hardware question, but this is also very
I realize this is a rather odd request, but I was wondering if anyone
I realize this is probably a hopelessly newbie question, but what is the difference
I realize this is a basic question but I have searched online, been to
I realize this sounds a little crazy, but I'm working on a project for
I realize this question is pretty basic, but I'm really stuck. I have a
I realize this is a duplicate of about 20 different posts, but none of
I realize this question has probably been asked numerous times, but I have not

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.