I am trying to parse XML file using NSXMLParser. Everything seems to work fine initially but the content result seems to be truncated off and got some weird result.
func parser(parser: NSXMLParser!, didStartElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: [NSObject : AnyObject]!) {
if elementName == "title" {
foundTitle = true
}
if elementName == "description" {
foundDescription = true
}
}
func parser(parser: NSXMLParser!, foundCharacters string: String!) {
if (foundItem) {
if foundTitle {
println("Title: \(string)")
foundTitle = false
}
else if foundDescription {
println("Description: \(string)")
foundDescription = false
}
}
}
The RSS feed I am testing on is This Day in Tech History (http://feedpress.me/ThisDayInTechHistory), and right now the first news have the following:
Title: IBM’s First Desktop Computer
Description: IBM introduces their System/23 Datamaster desktop computer...
Bur for my test result, this is what I got:
Title: IBM
Description: ’s First Desktop Computer
Description: July 28, 1981 IBM introduces their System/23 Datamaster desktop computer...
Note that the Title was truncated after the first ' and become a description! Is this a bug in NSXMLParser? Or what have I done wrong? Thanks!