Reputation: 579
I am working with the xml below is xml
<message xml="Local:client" type="message" to="123456@Local" from="147852369/a02c9bb1"><GET xml="http://Local.org/protocol/message"></GET></message>
Now how to get the value of "to"?.I tried with below code. But it is showing null value
[message elementForName:@"to" xml:@"Local:client"];
Please any body help me.
Upvotes: 1
Views: 56
Reputation: 799
Try following code snippet
func parser(parser: NSXMLParser,
didStartElement elementName: String,
namespaceURI: String?,
qualifiedName: String?,
attributes attributeDict: [NSObject : AnyObject]){
println("attributess name is \([attributeDict])")
if elementName=="message" {
let attrs = attributeDict
if let prop = attrs["to"] {
println("property 'to'=\(prop)")
}
}
}
Upvotes: 0
Reputation: 22374
message
is an element and to
is attribute of message element ...
To get to
from message use
[message attributeForName:@"to"]
Upvotes: 1