ios - Get attibuteDict of a subclass Xml parsing - Swift -


i want attribute of subclass of item :

  <pdv id="1000002" latitude="4621842" longitude="522767" cp="01000" pop="r"> <adresse>16 avenue de marboz</adresse> <ville>bourg-en-bresse</ville> <ouverture debut="01:00" fin="01:00" saufjour=""/> <services>   <service>automate cb</service>   <service>vente de gaz domestique</service> </services> <prix nom="gazole" id="1" maj="2015-05-30 11:30:17" valeur="1206"/> <prix nom="sp95" id="2" maj="2015-05-30 11:30:17" valeur="1398"/> <prix nom="sp98" id="6" maj="2015-05-30 11:30:17" valeur="1434"/> <rupture id="3" nom="e85" debut="2009-11-03 12:19:00" fin=""/> <fermeture/></pdv> 

i know how <pdv id="000"> attributedict try <prix nom="example">

i try code :

func beginparsing() {     parser = nsxmlparser(contentsofurl: testurl)!     parser.delegate = self     parser.parse() }  func parser(parser: nsxmlparser!, didstartelement elementname: string!, namespaceuri: string!, qualifiedname qname: string!, attributes attributedict: [nsobject : anyobject]!) {     element = elementname     if (elementname nsstring).isequaltostring("pdv")     {          cp = attributedict["cp"]! nsmutablestring         latitude = attributedict["latitude"]! nsmutablestring         longitude = attributedict["longitude"]! nsmutablestring          elements = nsmutabledictionary.alloc()         elements = [:]         prixcarbu = nsmutablestring.alloc()         prixcarbu = ""      }  }  func parser(parser: nsxmlparser!, foundcharacters string: nsstring!) {      if element.isequaltostring("prix") {         prixcarbu.appendstring(string)          func parser(parser: nsxmlparser!, didstartelement elementname: string!, namespaceuri: string!, qualifiedname: string!, attributes: [nsobject : anyobject]!) {              prixstring = elementname             if (elementname nsstring).isequal("prix") {                  println(attributes)              }          }      }  }   func parser(parser: nsxmlparser!, didendelement elementname: string!, namespaceuri: string!, qualifiedname qname: string!) {     if (elementname nsstring).isequaltostring("pdv") {         if !cp.isequal(nil) {             elements.setobject(cp, forkey: "cp")         }         if !latitude.isequal(nil) {             elements.setobject(latitude, forkey: "latitude")         }         if !longitude.isequal(nil) {             elements.setobject(longitude, forkey: "longitude")         }` 

thank's!

you should put "prix" check start element method. equivalent "pdv", use same mechanism.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -