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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:53:09+00:00 2026-05-29T19:53:09+00:00

The problem is I’ve got xml file with such structure …………………. <current_conditions> <condition data=partly

  • 0

The problem is

I’ve got xml file with such structure

......................
<current_conditions>
  <condition data="partly cloudy"/>
  <temp_f data="2"/>
  <temp_c data="-17"/>
  <humidity data="Huminidy: 66 %"/>
  <icon data="/ig/images/weather/partly_cloudy.gif"/>
  <wind_condition data="Wind: С, 2 м/с"/>
</current_conditions>
<forecast_conditions>
  <day_of_week data=""/>
  <low data="-23"/>
  <high data="-14"/>
  <icon data="/ig/images/weather/mostly_sunny.gif"/>
  <condition data="Mostly sunny"/>
</forecast_conditions>
.....................

I parse it like this

               while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        if (r.Name == "current_conditions")
                        {
                            string temp = "";
                            while (r.Read() && r.Name!="forecast_conditions")//I've addee this condition because it parse all nodes after "current conditions"
                            {
                                if (Current_Condtions.Contains(r.Name))
                                {
                                    temp += r.GetAttribute("data");
                                    temp += "\n";
                                }
                            }
                            Console.WriteLine(temp);
                        }
                    }
                }

I’ve added conditions but It still read file to the end, but I only want to parse from <current_conditions> to </current_conditions> and then stop reading xml file.
How to do 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-05-29T19:53:10+00:00Added an answer on May 29, 2026 at 7:53 pm

    The easiest way is to add a break; statement after you get the data you need.

    A cleaner way would be to use the ReadSubtree method. Use it to create a new reader once you’re on the current_conditions node. Then it will only read that node and its children.

    Something like

    r.ReadToFollowing("current_conditions")
    subtree = r.ReadSubtree()
    while(subtree.Read())
    {
        //Do your stuff with subtree...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: to find the right data structure for the queue: #include <stdio.h> #include <stdlib.h>
Problem I have timestamped data, which I need to search based on the timestamp
Problem! I Have the following input (rules) from a flat file (talking about numeric
Problem statement: I want to upload a large binary (such as an audio clip)
Problem: I call a PHP file using an HTTPService. I set the result of
Problem: I wrote a hello world java program, compiled and created a jar file
Problem I have a xib file with a UIImageView over the top of the
Problem: Find people whose birthdays are tomorrow (table a), who havent got a record
I'm parsing an XML file, the creators of it stuck in a bunch social
In my XML file chapters tag has more chapter tag.i need to display chapters

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.