I'm new to Swift and I'm trying to create an OSX terminal app to parse an xml file. I've got it reading the file in to a string, but cannot figure out how parse it in to a structure I can then navigate and pull data from. It appears that NSXMLDocument seems to want a URL and NSXMLParser needs a delegate, but my initial attempts could not get them to work.
Here's what I've got so far:
import Foundation
import Cocoa
let path = "//Users/<path>/someFile.xml"
var err: NSError?
let content = String.stringWithContentsOfFile(path, encoding: NSUTF8StringEncoding, error: &err)
The structure of the xml file is something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Documents>
<List>
<Document name="name1" type="TYPE1" date="some string">
<Items>
<Item name="item1" dataType="DATATYPE1" version="1">
<Item name="item2" dataType="DATATYPE9" version="4">
</Items>
</Document>
<Document name="name2" type="TYPE4" date="some string">
...
</List>
</Documents>
</Data>
Your help is much appreciated.