Latest 1.1.0
License MIT
Platforms ios 5.0, requires ARC

SHXMLParser Build Status Cocoa Pod

Easy to use automatic XML Parser built on NSXMLParser. Convert your XML data into native ‘Obj C object’ in just 2 steps.



  1. Add pod 'SHXMLParser' to your Podfile.
  2. Run pod install


Add the library folder SHXMLParser to your project.

How To Use:

XML Sample

        <item id='1'>
            <title>I am under surveillance by Canadian agents, my computer has been backdoored</title>
            <description><a href="">Comments</a></description>
        <item id='2'>
            <title>Why I Like Go</title>
            <description><a href="">Comments</a></description>

Use the below code to get the Array of Dictionary Objects from an XML like the one above.
Attributes will be taken automatically.

SHXMLParser     *parser         = [[SHXMLParser alloc] init];
NSDictionary    *resultObject   = [parser parseData:self.webServicesData];
NSArray         *dataArray      = [SHXMLParser getDataAtPath:@"" fromResultObject:resultObject];

Note: In case, the path used ("") contains only one item, NSDictionary will be returned instead of NSArray. If the path leads to leaf with just a string value,
string value will be returned.

If you want to convert dictionary objects in your data array into a class object for type safety, use code below.

NSArray *classVariables = [NSArray arrayWithObjects:@"title", @"link", @"comments", @"description", nil];
self.dataItems = [SHXMLParser convertDictionaryArray:dataArray toObjectArrayWithClassName:@"DataItem" classVariables:classVariables];

Note that for above conversion, class named ‘DataItem’ should contain public variables as mentioned in array ‘classVariables’, otherwise you will get runtime error.

Thats it, no need to write lot of node and element specific parsing code to retrieve data using NSXMLParser from XML data.

A small utility class method named getAsArray is there to get the nsdictionary object inside nsarray. This has been added because sometimes when the user is expecting an array from the parser it will be returned as nsdictionary if it contains only one object. Using this function will make sure that array is returned.


It requires iOS 5.0+ and uses ARC. It is built and tested using Xcode 4.5+.

Feel free to fork and update the library


MIT License

Latest podspec

    "name": "SHXMLParser",
    "version": "1.1.0",
    "summary": "Easy to use automatic XML Parser built on NSXMLParser. Get XML data as a single NSDictionary object or NSArray in just two steps.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Narasimharaj C": "[email protected]"
    "source": {
        "git": "",
        "tag": "v1.1.0"
    "platforms": {
        "ios": "5.0"
    "source_files": "SHXMLParser/*.{h,m}",
    "requires_arc": true

Pin It on Pinterest

Share This