I need to parse the xml data using nsxmlparser.But i am facing issue getting the required data and storing it to array or dictionary using swift.I have implemented the the delegate function and able to find the element name like this
func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [NSObject : AnyObject])
{
println(elementName)
if(elementName == "subCategories")
{
categoryName: String = [attributeDict valueForKey:"category"];
id = [attributeDict valueForKey:"id"];
name = [attributeDict valueForKey:"name"];
// Now You can store these in your preferable data models - data objects/array/dictionary
}
however m not able to implement the same using swift.My xml looks like this
<category>
<id>cat00000</id>
<name>Best Buy</name>
<active>true</active>
<path>
<category>
<id>cat00000</id>
<name>Best Buy</name>
</category>
</path>
<subCategories>
<category>
<id>abcat0100000</id>
<name>TV & Home Theater</name>
</category>
<category>
<id>abcat0200000</id>
<name>Audio</name>
</category>
<category>
<id>abcat0300000</id>
<name>Car Electronics & GPS</name>
</category>