Xml response in string, DidStartElement is not calling NSXMLParser

Here I am getting xml response in temp string. I need to get one tag value from that xml response.

-(void) httpDataDidFinishLoadingWithData:(NSData *)theData
{
    m_activityLoaded=NO;
    temp=[[NSString alloc] initWithData:[dataLoader httpData]  encoding:NSUTF8StringEncoding];
    NSLog(@"TEMP IS TEMP %@", temp);
    parser=[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:temp]];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    parser.delegate=self;
    [parser parse];
}

The problem is DidStartElement is not even calling after the above parser allocation and ready to parse.

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
    if(![elementName isEqual:@"Result"])
        return;
    woeid = [attributeDict objectForKey:@"woeid"];
    NSLog(@"woeid   %@", woeid);
}

My XML RESPONSE IS

<?xml version="1.0" encoding="UTF-8"?>
<Body><woied></woied></Body>

Please help me out of this guys. Thanks in Advance

Answers


You can try this :

-(void) httpDataDidFinishLoadingWithData:(NSData *)theData
{
    m_activityLoaded=NO;
    temp=[[NSString alloc] initWithData:[dataLoader httpData]  encoding:NSUTF8StringEncoding];
    NSLog(@"TEMP IS TEMP %@", temp);
    parser=[[NSXMLParser alloc] initWithData:[temp dataUsingEncoding: NSUTF8StringEncoding];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    parser.delegate=self;
    [parser parse];
}

I think this may be work.You were passing wrong data to parser.


? [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:temp]]; ?

Maybe you should create parser with [[NSXMLParser alloc] initWithData:theData];


Need Your Help

Validation Expression for asp.net

asp.net validation

I need to validate textbox value for a password, on client-side.

Is wmode=“transparent” attribute required in both the <object tag as well as the <embed tag?

html flash

To get flash to sit behind html elements on a page I read that I have to add this inside the object tag:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.