Here is my Code block for this,
var a = 0;
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
if error != nil {
println("error=\(error)")
return
}
responseString = NSString(data: data, encoding: NSUTF8StringEncoding)!
let xmlWithNamespace = responseString
var xml = SWXMLHash.parse(xmlWithNamespace)
var entity = xml["row"]["ftc"]["Entity"][a]
if entity.element?.attributes["ID"] != nil {
entity = xml["row"]["ftc"]["Entity"][a]
//println(a)
println(entity.element?.attributes["ID"])
a++
} else {
println("Print We Have Reached Our Limit")
}
}
task.resume()
I am trying to get an iterator to go through and print out all the children and attributes of these inside and store them in a variable.
I have been looking everywhere for some help but Swift and XML are just a headache - any help to get me to iterate through the node would be amazing, I tried to use a while loop but it just crashed the program after giving me the nodes.
I am trying to use this while loop but even that won't work,
while entity.element?.attributes["ID"] != nil {
entity = xml["row"]["ftc"]["Entity"][a]
//println(a)
println(entity.element?.attributes["ID"])
a++
break
}
Help would be appreciated it.