Q:

XML to JSON conversion in ios

i'm trying to convert a simple xml document in Xcode to JSON. The problem is keep returning nil.
This is my code:
NSURL *url = [[NSURL alloc] initFileURLWithPath:@"http://www.w3schools.com/xml/note.xml"];
NSData *xmlData = [[NSData alloc] initWithContentsOfURL:url];

NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLData:xmlData error:&parseError];

NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:xmlDictionary
                                                   options:NSJSONWritingPrettyPrinted
                                                     error:&error];
 NSLog(@"%@", jsonData);

Error message: 
[NSJSONSerialization dataWithJSONObject:options:error:]: value parameter is nil'

A:

As rmaddy said, try printing parseError. If parseError is Nil, then try printing the xmlDictionary, and check if the dictionary is created correctly.
If xmlDictionary is also Nil, then check the xmlData, which should be fine, in which case the dictionaryForXMLData method must be verified if it checks for any conditions.
Hope I helped.

