NSXMLParser在Swift中一个封装:VMXMLParser

jopen 10年前

NSXMLParser在Swift中一个封装:VMXMLParser。

特性:

1) Closure based

2) Response as array of dictionaries

3) Unicode support

Screenshot

dddd.png

Sample code

var url:String="http://www.varshylmobile.com/projects-1/iOS/sample1.xml"      VMXMLParser.initParserWithURLString(url, completionHandler: {          (tags, error) -> Void in          if(error != nil){              println(error)          }else{              println(tags!)          }          })

Sample response

( { description = "Does this parser work ?"; id = 1; location = India; name = "Jimmy Jose the swifter"; }, { description = "Running out of words now"; id = 2; location = USA; name = "Jimmy Jose the objector"; }, { description = "Jimmy Jose Varshyl Mobile"; id = 3; location = USA; name = "Varshyl Mobile"; }, { description = "Need to have better example next time"; id = 4; location = Delhi; name = Varshyl; }, { description = "I should have downloaded some sample xml file"; id = 5; location = Australia; name = "Varshyl Mobile XML Parser"; } )

项目主页:http://www.open-open.com/lib/view/home/1418097209323