Can some body help me why the below code is not working.. I am testing it in Xcode.1 Playground
let url:NSURL! = NSURL(fileURLWithPath:"file:///Users/sss/Documents/app.xml")
var xml = NSXMLParser(contentsOfURL: url)
xml?.parse()
Playgrounds are sandboxed, so you won't be able to just grab files from anywhere in your user folder. Here's how to add that file to your playground to make it accessible:
Now your file will be available inside the sandbox. You can retrieve it from the bundle and load it into the NSXMLParser
like this:
let url: NSURL! = NSBundle.mainBundle().URLForResource("app", withExtension: "xml")
var xml = NSXMLParser(contentsOfURL: url)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With