0

I'm getting a RSS feed from this URL. And I use the third-party library AEXML to parse it.

guard let data = try? Data(contentsOf: URL) else {
    return
}

do {
    let xmlDoc = try AEXMLDocument(xml: data)

    // ...

} catch let error as NSError {
    print("RSS parsing failed: \(error)")
}

Parsing the above feed fails with the following error.

Error Domain=NSXMLParserErrorDomain Code=9 "(null)" UserInfo={NSXMLParserErrorLineNumber=297, NSXMLParserErrorColumn=42, NSXMLParserErrorMessage=PCDATA invalid Char value 3

I tested the feed with an XML validator and this came up.

enter image description here

But I don't see any special characters there.

Either way, is there a way to escape these special/invalid characters?

This RSS feed is not mine so I cannot make any changes to the feed itself from their end. All I can do is find a way to workaround it from my end.

Isuru
  • 30,617
  • 60
  • 187
  • 303
  • 1
    The character value is 0x03 (Ctrl-C) and should not be there. Since you chose to post a clip from a screenshot all we can tell you is that whatever was displaying that text removed the special characters. You haven't really provided enough information for anyone to help you, however. – Jim Garrison Nov 08 '17 at 03:37
  • @JimGarrison I linked to the validator with the RSS feed I'm testing in the question. [Here is it again](https://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Ftopjobs.lk%2Frss%2Fteaching_academic_library.rss). Other than that I'm not sure what else I can post though. – Isuru Nov 08 '17 at 03:39
  • If the feed really contains 0x03 at that position it is NOT valid XML and cannot be processed as XML until you remove the invalid characters using some other means, such as streaming it through a filter that removes invalid data. Talk to the provider of the feed and inform them that it is not valid XML. – Jim Garrison Nov 08 '17 at 03:46

0 Answers0