Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmohundro/78146cf39bc152b9b1cd to your computer and use it in GitHub Desktop.
Save drmohundro/78146cf39bc152b9b1cd to your computer and use it in GitHub Desktop.
SWXMLHash Attribute Search Example
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"
}
@drmohundro
Copy link
Author

Updated to showcase new withAttr method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment