jweinst1
1/30/2017 - 10:22 PM

checks for text existence in child nodes

checks for text existence in child nodes

let xmlToParse = "<program><print><int>5</int><string>hello</string></print><add><int>5</int><int>0</int></add></program>"

let xml = SWXMLHash.parse(xmlToParse)
for child in xml["program"]["print"].children {
    print(child.element!.name)
    if let value = child.element!.text {
        print(value)
    }
}