1

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

1

2 Answers 2

4

Use: NSXMLParser & Darshan Answer

Sign up to request clarification or add additional context in comments.

Comments

2

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
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.