Why can my Xcode project see XMLParserDelegate but it can't see XMLDocument?

I am trying to read a straightforward XML file, but I can't get XMLDocument() -- Use of unresolved identifier 'XMLDocument'; did you mean 'UIDocument'?, although I can get XMLParserDelegate() to initialize with the same URL. What am I missing here?
Foundation has two XML APIs:
  • NSXMLDocument (XMLDocument in Swift) which is a document (tree) API

  • NSXMLParser (XMLParser in Swift) which is a streaming (SAX) API

On macOS, you can use either. On iOS-based platforms, only NSXMLParser is available. Thus, you have a couple of choices:
  • You can switch to the streaming model.

  • If you absolutely need to use the document model, you can use the lower-level APIs in libxml2.

If you do the latter, it’s probably be worth looking for a third-party wrapper library because libxml2 is a low-level C API that’s not much fun to call directly from Swift.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Why can my Xcode project see XMLParserDelegate but it can't see XMLDocument?
 
 
Q