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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:06:47+00:00 2026-06-17T08:06:47+00:00

This is my XML data that I need to parse <GetMessagesResult> <NewDataSet xmlns=> <Table>

  • 0

This is my XML data that I need to parse

 <GetMessagesResult>
    <NewDataSet xmlns="">
       <Table>
          <Date>21:52:59</Date>
          <Message>ABC</Message>
          <GroupName>ALL</GroupName>
       </Table>
       <Table>
          <Date>11:23:27</Date>
          <Message>DEF</Message>
          <GroupName>ALL</GroupName>
       </Table>
   </NewDataSet>
 </GetMessagesResult>

This is my SCMessages.h file

#import <Foundation/Foundation.h>
@interface SCMessages : NSObject
{
    NSDate *Date;
    NSString *Message;
    NSString *GroupName;
}
@property (nonatomic, retain) NSDate *Date;
@property (nonatomic, retain) NSString *Message;
@property (nonatomic, retain) NSString *GroupName;

and this is my SCMessages.m file

#import "SCMessages.h"
@implementation SCMessages
@synthesize Date;
@synthesize Message,GroupName;
- (void)dealloc
{
    [super dealloc];
    [Date release];
    [Message release];
    [GroupName release];
}
@end

I used below code to parse the data using NSXMLParser delegate methods

#pragma mark - NSXMLParser Delegate

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
   attributes: (NSDictionary *)attributeDict
{
    if( [elementName isEqualToString:@"GetMessagesResult"])
    {
        if(!soapResults)
        soapResults = [[NSMutableString alloc] init];
        recordResults = TRUE;
    }

    if([elementName isEqualToString:@"NewDataSet"]) {
        //Initialize the array.
        messages = [[NSMutableArray alloc] init];
    }
    else if([elementName isEqualToString:@"Table"]) {
        //Initialize the message.
        aMessage = [[SCMessages alloc] init];
    }
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if( recordResults )
        [soapResults appendString: string];
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if([elementName isEqualToString:@"Table"]) {
        [messages addObject:aMessage];
            NSLog(@"MESSAGES COUNT: %d",messages.count);
            NSLog(@"MESSAGE: %@",aMessage);
        [aMessage release];
        aMessage = nil;
    }
    // as this is the last element
    if( [elementName isEqualToString:@"NewDataSet"])
    {
        recordResults = FALSE;
    }
}

PROBLEM I am not getting the desired message object with Date, Meesage & GroupName.

I put NSLog to print them but I always get null value. The weird thing is message array gets allocated memory & also elements gets added to array as I can see message array count in NSLog but the array element has data as null value.

I am parsing the XML data received in SOAP response in NSURLConnection delegate method connectionDidFinishLoading

NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(@"theXML: \n%@",theXML);
  • 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-17T08:06:48+00:00Added an answer on June 17, 2026 at 8:06 am

    You need to store your values in aMessage. You have added particular object to array but you forgot to store data in that object of SCMessages class.You can also check while debug that you are getting value in aMessage object.

    You need to store value like this in this didEndElement method.

     [aMessage setValue: soapResults forKey:elementName];
    

    I think this will help you.

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

Sidebar

Related Questions

i have the following XML that i need to parse in C#: <data> <customer_id><![CDATA[1414301]]></customer_id>
How to change my query so that this error doesn't happen: XML data type
Our C++ application reads configuration data from XML files that look something like this:
I have some data in an XML element that looks like this: <?xml version=1.0
I have an xml that goes like this: <Equipment> <ModificationDate> <Data> </Data> </ModificationDate> </Equipment>
i've developed an android app that's fetches an xml file and displays this data
I have an xml file that I need to load. This xml file holds
I have two XML files that I need to parse into one record. The
I have a very large XML file that I need to parse so I
how do i parse this xml data's Question element into an object called question

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.