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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:00:17+00:00 2026-05-22T18:00:17+00:00

I have an the following xml file. I want to parse the elements current_date_time

  • 0

I have an the following xml file. I want to parse the elements current_date_time, condition, humidity, icon, wind_condition, low, high. All these elements include attributes. I know how to parse a simple xml file. But all these elements contains attribute values.

So how would I parse this xml file?

    <?xml version="1.0" ?> 
    <xml_api_reply version="1">
        <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0">
            <forecast_information>
                <city data="" /> 
                <postal_code data="" /> 
                <latitude_e6 data="50500000" /> 
                <longitude_e6 data="30500000" /> 
                <forecast_date data="2011-05-27" /> 
                <current_date_time data="2011-05-27 04:30:00 +0000" /> 
                <unit_system data="US" /> 
            </forecast_information>
            <current_conditions>
                <condition data="Clear" /> 
                <temp_f data="57" /> 
                <temp_c data="14" /> 
                <humidity data="Humidity: 59%" /> 
                <icon data="http://g0.gstatic.com/images/icons/onebox/weather_sunny-40.gif" /> 
                <wind_condition data="Wind: S at 9 mph" /> 
            </current_conditions>
            <forecast_conditions>
                <day_of_week data="Fri" /> 
                <low data="54" /> 
                <high data="72" /> 
                <icon data="http://g0.gstatic.com/images/icons/onebox/weather_partlycloudy-40.gif" /> 
                <condition data="Mostly Sunny" /> 
            </forecast_conditions>
            <forecast_conditions>
                <day_of_week data="Sat" /> 
                <low data="52" /> 
                <high data="79" /> 
                <icon data="http://g0.gstatic.com/images/icons/onebox/weather_partlycloudy-40.gif" /> 
                <condition data="Mostly Sunny" /> 
            </forecast_conditions>
            <forecast_conditions>
                <day_of_week data="Sun" /> 
                <low data="55" /> 
                <high data="84" /> 
                <icon data="http://g0.gstatic.com/images/icons/onebox/weather_partlycloudy-40.gif" /> 
                <condition data="Mostly Sunny" /> 
            </forecast_conditions>
            <forecast_conditions>
                <day_of_week data="Mon" /> 
                <low data="63" /> 
                <high data="84" /> 
                <icon data="http://g0.gstatic.com/images/icons/onebox/weather_partlycloudy-40.gif" /> 
                <condition data="Mostly Sunny" /> 
            </forecast_conditions>
        </weather>
    </xml_api_reply>


    Please help me in solving this problem. Thanks. Can anybody provide me any sample code on this?


i have done this code to parse the above xml file but my problem is checks only the first xml tag i.e the root element xml_ap_reply for every checking

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString*) elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{


if ([elementName isEqualToString:@"xml_api_reply"])
    {
        mWeather = [[TWeatherElement alloc]init];


    }

     if([elementName isEqualToString:@"current_date_time"])
    {
         NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


         [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

     if([elementName isEqualToString:@"condition"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

     if([elementName isEqualToString:@"humidity"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

     if([elementName isEqualToString:@"icon"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }   
     if([elementName isEqualToString:@"wind_condition"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

     if([elementName isEqualToString:@"low"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

     if([elementName isEqualToString:@"high"])
    {
        NSMutableArray *temp=[[NSMutableArray alloc]init];
        self.mParserArray=temp;
        [temp release];


        [mParserArray addObject:[attributeDict valueForKey:@"data"]];

    }

please help me in solving this problem.Thanks

  • 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-22T18:00:18+00:00Added an answer on May 22, 2026 at 6:00 pm

    suppose <postal_code data="" />
    and you want data value so what you have to do is:

    -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{         
    
        if([elementName isEqualToString:@"postal_code"])
        {
            NSMutableArray *temp = [[NSMutableArray alloc] init];
            self.registrationResponseArray = temp;
            [temp release];
    
            [registrationResponseArray addObject:[attributeDict valueForKey:@"data"]];  
        }
    }
    

    [attributeDict valueForKey:@"data"] will give you the attribute value, then you can add anywhere (whatever structure you are using).

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

Sidebar

Related Questions

I have the following very simple XML file and I want to quickly parse
I have the following xml file and want to parse it into an .aspx
I have the following XML file: <xml version=1.0 encoding=utf-8?> <Data> <Parameter1>1</Parameter1> </Data> I want
I have the following XML file and I want to store it using the
I have a file that keeps appending the following xml. What I want to
I have a simple but huge xml file like below. I want to parse
I want to parse text from a xml file.Consider that I have a some
I have the following XML file with page nodes which I want to read
Imagine I have the folling XML file: <a>before<b>middle</b>after</a> I want to convert it into
I have the following xml file: <xfa:data> <form1> <Page1> <Page2> <contractInfo> ... </contractInfo> <paymentInfo>

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.