Reputation: 33
I download an XML file that contains several URLs. It works fine, but when I enter a URL in the XML like this:
the parser stops.
From what I understand is that the URL contains special characters, I have sought and given as a possible solution the following code, where information is encoded to UTF8 before parsing:
NSString *dataString = [[NSString alloc] initWithContentsOfURL:URL encoding:NSUTF8StringEncoding error:error];
NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
[parser setDelegate:self];
[parser parse];
It does not work. Stop parsing in this method
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict
Any ideas?
Thanks.
Upvotes: 1
Views: 184
Reputation: 33
the solution was using the field
<![CDATA[http://eda-bea.es/pub/record_card_1.php?refpage=%252Fpub%252Fsearch_select.php&quicksearch=adra&page=1&rec=3]]>
Upvotes: 1
Reputation: 42588
Changed Answer
This link http://eda-bea.es/pub/record_card_1.php?refpage=%252Fpub%252Fsearch_select.php&quicksearch=adra&page=1&rec=3 is not an XML document, it's an HTML document.
The parser will fail on <link rel="stylesheet" type="text/css" href="images.php/hispep.css">
because here is no end link tag.
Upvotes: 0