Last active
August 29, 2015 14:08
-
-
Save drmohundro/78146cf39bc152b9b1cd to your computer and use it in GitHub Desktop.
SWXMLHash Attribute Search Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = "<Conversations>" + | |
"<Conversation id=\"ConvTest1\">" + | |
"<StartingStatementId>1</StartingStatementId>" + | |
"<Description>Some description 1</Description>" + | |
"</Conversation>" + | |
"<Conversation id=\"ConvTest2\">" + | |
"<StartingStatementId>2</StartingStatementId>" + | |
"<Description>Some description 2</Description>" + | |
"</Conversation>" + | |
"</Conversations>" | |
var xml = SWXMLHash.parse(data) | |
if let match = xml["Conversations"]["Conversation"].withAttr("id", "ConvTest2").element? { | |
NSLog(match["Description"].element!.text!) // will display "Some description 2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to showcase new
withAttr
method.