Reputation: 1426
I am trying to parse this xml to my application, but my NSDictionary is always nil when I debug
This xml
<DADOS_MESA>
<MESA>
<Id>1076</Id>
<Date>2015-05-08T09:44:25.343</Date>
</MESA>
<DADOS_MESA>
I am requesting this XML from my WS, with
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://myIP/Services.asmx/GetDetails?CId=02&SId=01"]];
Then I create an NSDictionary
NSDictionary *xml = [NSDictionary dictionaryWithContentsOfURL:url];
The NSDictionary always come nil(I don't know why), Thanks
Upvotes: 1
Views: 1127
Reputation: 2052
You could use the NSXMLParser to do this. Here is a sample code.
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://myIP/Services.asmx/GetDetails?CId=02&SId=01"]];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
parser.delegate = self;
[parser parse];
-(void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
{
//Use attributeDict to get parsed XML into NSDictionary
}
Upvotes: 2