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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:46:57+00:00 2026-06-02T11:46:57+00:00

This is the link for my xml data http://api.worldbank.org/countries/IND/indicators/EN.ATM.CO2E.PC?per_page=10&date=2005:2012 i am using the following

  • 0

This is the link for my xml data

http://api.worldbank.org/countries/IND/indicators/EN.ATM.CO2E.PC?per_page=10&date=2005:2012

i am using the following code to parse it and display but unable to do so.

 public void Getinfo()
    {
        try
        {
           String url = http://api.worldbank.org/countries/IND/indicators/EN.ATM.CO2E.PC?per_page=10&date=2005:2012";
            WebClient wc = new WebClient();
            wc.OpenReadCompleted += wc_OpenReadCompleted;
            wc.OpenReadAsync(new Uri(url));



        }
        catch (Exception)
        {
            MessageBox.Show("Please retry unable to access Data");

        }
    }
    private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        if (e.Error != null)
        {
            MessageBox.Show(e.Error + "");
            return;
        }
        using (Stream s = e.Result)
        {
            XDocument doc = XDocument.Load(s);
            XNamespace wb = "http://www.worldbank.org";

            foreach (var node in doc.Element(wb+"data").Element(wb+"data").Elements(wb+"date"))
            {
               String chk = node.Value.ToString();
               String year1 = "2007";
                if (chk == year1)
                {
                    foreach (var node1 in doc.Element(wb+"data").Element(wb+"data").Elements(wb+"value"))
                    {
                        info1.Text = node1.Value.ToString();
                    }

                }
  • 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-02T11:47:00+00:00Added an answer on June 2, 2026 at 11:47 am

    The problem comes from your Linq request:

    What you are doing here:

    You take the first data element, then you take the first data element again in the previous, and then you take all the date in that second data element.

    data --> enter here
    -- data --> then here
    -- -- date --> and take all the date element in the parent data node
                   (but there is only one date element per data)
    -- data
    -- -- date
    

    What you want to do is:

    Take all the data element at the second level, but don’t take the whole element, just the first date element of each data element.

    foreach (var date in doc.Element(wb + "data").Elements(wb + "data").Select(data => data.Element(wb + "date")))
    {
        ...
    }
    

    What you want to achieve isn’t clear for me, but then if you need the value element in the same data element, maybe it isn’t necessary to return only the date.

    Also, why do you use a second foreach statement? Once again, you’ll only receive one element with that request. I guess what you want to do is something like this:

    foreach (var node in doc.Element(wb + "data").Elements(wb + "data"))
    {
        if("2007".Equals(node.Element(wb + "date").Value){
            info1.Text = node.Element(wb + "value").Value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to Unmarshal the following xml: <datas xmlns=http://www... xmlns:atom=http://www.w3.org/2005/atom> <data> <atom:link rel=data
I have a link from that link: http://api.maxxiscentral.com/maxxiscentral/GetTyrePatterns from this link i want to
This link http://ajaxcontroltoolkit.codeplex.com/releases/view/11121#DownloadId=28808 shows a popup on which one has to agree before being
This link shows you that jQuery uses (new Function(return + data))(); for older browsers,
In this link: http://css-tricks.com/snippets/jquery/jquery-plugin-template/ it has a line of code that says // Add
Why does parser is cutting url to this: inside node: http://img844.imageshack.us/content.php?page=done&amp;l=img844/4783/php4dd.jpg after parse: [done_page]
My data is an xml element & I want send PUT request with JavaScript.
Below is my code: foreach(simplexml_load_file('http://www.bbc.co.uk/radio1/playlist.xml')->item as $link){ $linked = $link->artist; $xml_data = file_get_contents('http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist=' .
I got this code for a parser from this link. http://www.warriorpoint.com/blog/2009/07/19/android-simplified-source-code-for-parsing-and-working-with-xml-data-and-web-services-in-android/ I am getting
I'm trying to parse some XML I've gotten from the Google Data Booksearch API

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.