Latest 0.0.2
License MIT
Platforms ios 8.0
Dependencies KissXML



XMLModelizer is a simple XML Parser and Modelizer.
Once you give model class and XML URL to XMLModelizer, you can get model instances that have XML elements which you need.


In case you want to get title, link, content:media, category, and pubDate values of each item tag in the xml below.

<rss xmlns:dc="" xmlns:media="" xmlns:atom="" xmlns:nyt="" version="2.0">
                Xi Jinping May Delay Picking China’s Next Leader, Stoking Speculation
</link> <guid isPermaLink="true"> </guid> <atom:link rel="standout" href=""/> <media:content url="" medium="image" height="151" width="151"/> <media:description> President Xi Jinping of China during a ceremony observing Martyrs’ Day, a holiday that memorializes Chinese who died in battle against foreign powers, at Tiananmen Square in Beijing last week. </media:description> <media:credit>Mark Schiefelbein/Associated Press</media:credit> <description> The apparent plan by the Chinese president has unsettled the party elite and created uncertainty over whether Mr. Xi will try to stay in power beyond the usual two terms. </description> <dc:creator>CHRIS BUCKLEY</dc:creator> <pubDate>Tue, 04 Oct 2016 23:59:10 GMT</pubDate> <category domain="">Xi Jinping</category> <category domain="">Communist Party of China</category> <category domain="">China</category> <category domain="">Appointments and Executive Changes</category> <category domain="">Li Keqiang</category> <category domain=""> Politburo Standing Committee of the Communist Party of China </category> </item> <item>...

First, define your custom model extends XMLModelizerModel and override xmlModelizerXpathKeyMap function and add properties you want.

import XMLModelizer

class NYTimesArticle: XMLModelizerModel {

    //Add properties you want to get from xml.
    var title: [String]! // please define properties as [String]!
    var link: [String]!
    var media: [String]!
    var category: [String]!
    var pubDate: [String]!

    //Please define xpath to get contents of xml.
    //In dictionary, key is your property, and value is xpath of its key.
    // [property : xpath]
    override class func xmlModelizerXpathKeyMap() -> [String:String] {
        return [

Finally, you can get Array<NYTimesArticle> by

import XMLModelizer
// open static func modelize(modelClass: XMLModelizerModel.Type, urlString: String) -> [AnyObject]
let nytimesArticles: Array<NYTimesArticle> = XMLModelizer.modelize(NYTimesArticle.self, "")

let article: NYTimesArticle = nytimesArticles.first
print(article.title.first) // "Xi Jinping May Delay Picking China’s Next Leader, Stoking Speculation"
print(article.category[1])// "Communist Party of China"


If you get error “Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly. in Xcode8, please set XMLModelizer’s plist’s “Use Legacy Swift Language Version” No in your Pods project.


iOS 8.0 or above.


XMLModelizer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "XMLModelizer"


Aoi Fukuoka, [email protected]


XMLModelizer is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "XMLModelizer",
    "version": "0.0.2",
    "summary": "XMLModelizer is a simple XML Parser and Modelizer.",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "homepage": "",
    "authors": {
        "Aoi Fukuoka": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.0.2"
    "platforms": {
        "ios": "8.0"
    "source_files": "XMLModelizer/**/*.{h,m,swift}",
    "dependencies": {
        "KissXML": [
    "description": "XMLModelizer is a XML Parser, also instance, that have each xml element, generator(modelizer). nOnce you give model class and XML URL to XMLModelizer, you can get model instances that have XML elements which you need as properties(it needs only one line!!)."

Pin It on Pinterest

Share This