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

  • Home
  • SEARCH
  • 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 6152555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:56:24+00:00 2026-05-23T19:56:24+00:00

yesterday i did ask about how to extract some data from a complicated xml

  • 0

yesterday i did ask about how to extract some data from a complicated xml file , using web service, on the Windows Phone 7 , but unfortuntly i did not get an answer, and i’m still stuck.
This is the c# code i wrote and did not display the data on my application’s screen:

    public MainPage()
    {
        InitializeComponent();

        SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

        Uri url = new Uri("http://www.google.com/ig/api?weather=paris", UriKind.Absolute);
        WebClient client = new WebClient();
        client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
        client.DownloadStringAsync(url);
    }


 void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            ListBoxItem areaItem = null;
            StringReader stream = new StringReader(e.Result);
            XmlReader reader = XmlReader.Create(stream);
            string day = String.Empty;
            string areaName = String.Empty;
            string low = String.Empty;
            string high = String.Empty;
            string condition = String.Empty;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {

                        case ("day_of_week"):
                            {
                                if (true == reader.MoveToFirstAttribute())
                                {
                                    reader.MoveToContent();
                                    day = reader.ReadElementContentAsString();
                                    day = reader.Value.ToString();
                                    areaItem = new ListBoxItem();
                                    areaItem.Content = day;
                                    listBox1.Items.Add(areaItem);
                                }

                            } break;
                        case ("low"):
                            {
                                if (true == reader.MoveToFirstAttribute())
                                {
                                    reader.MoveToContent();
                                    low = reader.ReadElementContentAsString();
                                    low = reader.Value.ToString();
                                    areaItem = new ListBoxItem();
                                    areaItem.Content = low;
                                    listBox1.Items.Add(areaItem);
                                }

                            } break;
                        case ("high"):
                            {
                                if (true == reader.MoveToFirstAttribute())
                                {
                                    reader.MoveToContent();
                                    high = reader.ReadElementContentAsString();
                                    high = reader.Value.ToString();
                                    areaItem = new ListBoxItem();
                                    areaItem.Content = high;
                                    listBox1.Items.Add(areaItem);
                                }

                            } break;
                        case ("condition"):
                            {
                                if (true == reader.MoveToFirstAttribute())
                                {
                                    reader.MoveToContent();
                                    condition = reader.ReadElementContentAsString();
                                    condition = reader.Value.ToString();
                                    areaItem = new ListBoxItem();
                                    areaItem.Content = condition;
                                    listBox1.Items.Add(areaItem);
                                }

                            } break;
                    }
                }

            }
        }      

    }
}

}

  • 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-23T19:56:24+00:00Added an answer on May 23, 2026 at 7:56 pm

    You are overcomplicating everything, its really simple, use the

    public class ForecastItem
    {
     public string a {get; set;}
     public string b {get; set;}
    }
    

    and so on

    private void forecastReader_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs dc)
        {
            if (dc.Error != null)
            {
                return;
            }
            XElement xmlNews = XElement.Parse(dc.Result);
            listBox1.ItemsSource = from item in xmlNews.Descendants("parent").Elements("sub")
                                   select new ForecastItem
                                   {
                                       a = item.Element("node").Value,
                                       b = item.Element("title").Value,                                       
                                   };
        }
    

    all you do from here on is Bind the Data to your XAML data template

    Article Here

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

Sidebar

Related Questions

I made a question yesterday about this, but I did some changes in my
Since my question from yesterday was perhaps not completely clear and I did not
Yesterday I had to parse a very simple binary data file - the rule
So i did read a lot about Azure yesterday as i'm considering my plans
Following yesterday's question, I did some research and I thought I had a more
Yesterday, I have a discussion with my colleagues about HTTP. It is asked why
Yesterday I got a call from a Microsoft representative asking if we supply hosted
I am new to c#/.net and just switched over to it from classic asp(yesterday).
So yesterday I did a fresh install of Ubuntu11.10 but keeping my home directory
Yesterday Tomcat was running ok, but today when I try to run my web-app

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.