Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>NSXMLParser</code> doesn't parse the data into a <code>NSDictionary</code> for you, it'll loop through all the elements, and you'll need to get the values that you need using its delegate (<code>NSXMLParserDelegate</code>).</p> <p>There are frameworks, such as <a href="https://github.com/amarcadet/XMLReader" rel="nofollow noreferrer">XMLReader</a> (which actually uses <code>NSXMLParser</code>), that handles the parsing of all elements into a <code>NSDictionary</code> or <code>NSArray</code> (depending on how the xml is formatted).</p> <p><code>NSLog(@" iiiiii %@",xmlParser);</code> will show the description of a <code>NSXMLParser</code> object, and outputs correctly (it's not supposed to show the parsed content).</p> <p>Regarding the <code>&amp;</code> characters, those are encoded <a href="https://stackoverflow.com/questions/1105169/html-character-decoding-in-objective-c-cocoa-touch">html characters</a>. There may be an issue on the server, since it returns part of the xml encoded, and part of it decoded.</p> <p><strong>EDIT:</strong></p> <p>This needs to be added in a NSString category, and you can afterwards call this method on your string from the server response.</p> <pre><code>-(NSString *)xmlDecodedString{ NSMutableString *ret = [[NSMutableString alloc] initWithCapacity:self.length]; NSRange specialRange = NSMakeRange(NSNotFound, NSNotFound); // using %c causes some issues NSRange decRange = NSMakeRange(0, NSNotFound); for (NSUInteger i=0; i&lt;[self length]; i++) { char c = [self characterAtIndex:i]; if (specialRange.location==NSNotFound) { // search for the start of a special 'character' (starts with '&amp;') if (c == '&amp;'){ if (i&gt;decRange.location) { decRange.length=i-decRange.location; [ret appendString:[self substringWithRange:decRange]]; decRange = NSMakeRange(i+1, NSNotFound); } specialRange.location=i; } } else{ // search for the end of the special 'character' (ends with ';') if (c == ';'){ decRange = NSMakeRange(i+1, NSNotFound); specialRange.length=i-specialRange.location+1; NSString *special = [self substringWithRange:specialRange]; specialRange = NSMakeRange(NSNotFound, NSNotFound); if ([special isEqualToString:@"&amp;quot;"]) { [ret appendString:@"\""]; } else if([special isEqualToString:@"&amp;#x27;"]){ [ret appendString:@"'"]; } else if([special isEqualToString:@"&amp;lt;"]){ [ret appendString:@"&lt;"]; } else if([special isEqualToString:@"&amp;gt;"]){ [ret appendString:@"&gt;"]; } else if([special isEqualToString:@"&amp;amp;"]){ [ret appendString:@"&amp;"]; } else{ DLogWarn(@"WARNING: unhandled special entity %@", special); [ret appendString:special]; } } } } if (self.length&gt;decRange.location) { decRange.length=self.length-decRange.location; [ret appendString:[self substringWithRange:decRange]]; } return [ret autorelease]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload