Click here to Skip to main content
12,948,130 members (77,323 online)

parsing xml in iphone not gettig value

cutie1 asked:

Open original thread

I need to call a XML file from a WCF Service and Parse the content of XML in iPhone.
I m able to call the service url but when doing parsing using NSXMLParser I couldn't get a patricular attribute value in XML .I m using a ViewController application in XCode.

My XML file is like this :
<GetCompanyResponse xmlns="" xmlns:i="

I have tried this code :
NSString *urlString = [NSString stringWithFormat:@"
NSURL *jsonUrl =[NSURL URLWithString:urlString];

 NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:jsonUrl];
    [parser setDelegate:self];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    [parser parse];
    [parser release];  
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:
(NSString *)qName attributes:(NSDictionary *)attributeDict
    if ([elementName isEqualToString:@"Company"]) {
        NSString *name=[attributeDict objectForKey:@"Id"];

But when I check for the value in 'name' it is returning nil.Couldn't get where I m I going wrong?What should I change?How can I get the value in ID attribute?

Any help would be appreciated..

Thanks in advance..
Tags: Mobile (iPhone)


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100