Skip to content

Instantly share code, notes, and snippets.

Last active August 24, 2020 16:36
What would you like to do?
StackOverflow Question - SWXMLHash Test
import SWXMLHash
let xml = """
var parsedXML: XMLIndexer? = nil
parsedXML = SWXMLHash.parse(xml)
let name1 = parsedXML?["root"]["catalog"]["book"][0]["author"].element?.text
let name2 = parsedXML?["root"]["catalog"]["book"][1]["author"].element?.text
let name3 = parsedXML?["root"]["catalog"]["book"][2]["author"].element?.text
let catalog = parsedXML?["root"]["catalog"]
let subname1 = catalog?["book"][0]["author"].element?.text
let subname2 = catalog?["book"][1]["author"].element?.text
let subname3 = catalog?["book"][2]["author"].element?.text
Copy link

Seems to work?

SWXMLHashPlayground playground 2020-08-24 11-34-41

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