-1

I am doing XMLParsing for my app. To get the parsed value in dictionary i have used XMLReader.h and XMLReader.m file. It works for all web services but returns null. It gives me correct response in XML format.

Here is the code where I get the values in dictionary

-(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string
{

    if(elementFound)
    {
        [soapResults appendString:string];
        NSLog(@"soap result of hotel  is %@",soapResults);
        NSError *parseError = nil;
        NSDictionary *xmlDixtionary =  [XMLReader dictionaryForXMLString:soapResults error:&parseError];

        NSLog(@"dictionary is  is %@",xmlDixtionary);
    }

}

But the log gives me a null value , what should I do to get the values in dictionary?

DarkAjax
  • 15,955
  • 11
  • 53
  • 65
Purva
  • 1,291
  • 2
  • 15
  • 30

2 Answers2

1

soapResults isn't the full string that you are searching for, you have just append a piece of string to it.You need to keep appending characters and to create the dictionary only at the end of the element.

Implement this method:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
1

I found Something for you : XML Parsing - NSXMLParserErrorDomain error 5

It shows the possibility of problem in encoding.

One more link : [iPhone] Can not parse simple XML

Hope It will be useful for you.

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94
  • i am not using any xml file instead i am getting the esponse in xml format, btw thanks. – Purva Dec 27 '12 at 16:08