Hello. I'm seeing a lot online about how to initialize XMLParser but not on how to use the data.
Basically, I have this so far in my ViewController:
class MyViewController: UIViewController, XMLParserDelegate {
@IBOutlet weak var personName: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
let dataURL = URL(string: "http://mysite.com/data.xml")
let parser = XMLParser(contentsOf: dataURL)
parser?.delegate = self
parser?.parse()
}
}
XMLParser returns true, but I'm not sure what to do now about populating the UILabel personName.
We can say the XML looks something like this:
<Person>
<Name>Bob</Name>
</Person>
Any tips on the best practices on populating objects with the data? Thanks!