I am trying to parse a URL with an &
in the URL:
ViewArticle.dbml?DB_OEM_ID=1800&ATCLID=3664162
..but using NSXMLParser, all i get is 1800ATCL
. It completely ignores the &
.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if (qName) {
elementName = qName;
}
if ([elementName isEqualToString:@"title"]) {
self.contentOfCurrentNewsProperty = [NSMutableString string];
}else if ([elementName isEqualToString:@"link"]){
self.contentOfCurrentNewsProperty = [NSMutableString string];
}else {
self.contentOfCurrentNewsProperty = nil;
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if (qName) {
elementName = qName;
}
_currentElement = elementName;
if ([elementName isEqualToString:@"title"]) {
self.currentNewsObject.title = self.contentOfCurrentNewsProperty;
} else if ([elementName isEqualToString:@"link"]){
self.currentNewsObject.link = self.contentOfCurrentNewsProperty;
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (self.contentOfCurrentNewsProperty) {
[self.contentOfCurrentNewsProperty appendString:string];
}
}
Any ideas? Thanks
Edit: I did a little more testing and the line <?xml version="1.0" encoding="windows-1252"?>
is what is messing it up, but this is embedded in the xml file, any way to get around it?**