Note that there are some explanatory texts on larger screens.

plurals
  1. PONSXMLParser stops parsing after encountering special character
    text
    copied!<p>I am reading a XML file from google weather api and parsing it using NSXMLParser. The city in question is Paris. Here is a brief xml output I get</p> <pre><code> &lt;?xml version="1.0"?&gt; &lt;xml_api_reply version="1"&gt; &lt;weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" &gt;&lt;forecast_information&gt; &lt;city data="Paris, Île-de-France"/&gt; &lt;postal_code data="Paris"/&gt; &lt;latitude_e6 data=""/&gt; &lt;longitude_e6 data=""/&gt; ... ... </code></pre> <p>Now the code I used to pares this xml is</p> <pre><code>NSString *address = @"http://www.google.com/ig/api?weather=Paris"; NSURL *URL = [NSURL URLWithString:address]; NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL]; [parser setDelegate:self]; [parser parse]; ... - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict { NSLog(@"XML Parser 1 ... elementName ... %@", elementName); } </code></pre> <p>This is output that I get for the above xml</p> <pre><code>XML Parser 1 ... elementName ... xml_api_reply XML Parser 1 ... elementName ... weather XML Parser 1 ... elementName ... forecast_information </code></pre> <p>The problem is that it parses all the tags till it reaches "city data" since there is a non-ascii character in the name Paris, Île-de-France and then it just stops. It doesn't process tags afterwards like postal_code. latitude, longitude etc.</p> <p>So my question is, is there a way I can remove all non-ascii characters from the returned URL XML string?</p>
 

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