{"id":16209167,"url":"https://github.com/erkanyildiz/eyxml2nsdictionary","last_synced_at":"2026-05-02T02:39:26.376Z","repository":{"id":80340915,"uuid":"70583029","full_name":"erkanyildiz/EYXML2NSDictionary","owner":"erkanyildiz","description":"A block based NSXMLParser wrapper for converting XML to NSDictionary on background thread","archived":false,"fork":false,"pushed_at":"2018-03-04T16:07:38.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T22:18:57.709Z","etag":null,"topics":["background-thread","dictionary","ios","macos","nsxmlparser","nsxmlparser-wrapper","objective-c","parser","tvos","watchos","xml"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erkanyildiz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-11T10:37:06.000Z","updated_at":"2018-12-11T09:07:42.000Z","dependencies_parsed_at":"2023-06-05T21:30:49.818Z","dependency_job_id":null,"html_url":"https://github.com/erkanyildiz/EYXML2NSDictionary","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkanyildiz%2FEYXML2NSDictionary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkanyildiz%2FEYXML2NSDictionary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkanyildiz%2FEYXML2NSDictionary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erkanyildiz%2FEYXML2NSDictionary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erkanyildiz","download_url":"https://codeload.github.com/erkanyildiz/EYXML2NSDictionary/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247728273,"owners_count":20986244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-thread","dictionary","ios","macos","nsxmlparser","nsxmlparser-wrapper","objective-c","parser","tvos","watchos","xml"],"created_at":"2024-10-10T10:28:19.257Z","updated_at":"2026-05-02T02:39:26.322Z","avatar_url":"https://github.com/erkanyildiz.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EYXML2NSDictionary\nAn `NSXMLParser` wrapper for converting XML to `NSDictionary` with blocks and background threading.\n\n- Based on powerful built-in `NSXMLParser`\n- Asynchronous parsing and completion block with resulting `NSDictionary` or `NSError`\n- Background threading for not blocking UI while parsing\n- Adding attibutes as key-value pairs after prefixing keys with `-` to prevent collision\n- Converting repeating elements to proper arrays\n- Handling inner texts among tags as an array using `-InnerText` key  \n- Excluding comments in resulting `NSDictionary`\n\n\n## Usage\n\n- With XML data as `NSData`\n\n```\nNSData* XMLData = [Read from disk or fetch from network];\n\n[EYXML2NSDictionary parseXMLData:XMLData completion:^(NSDictionary* dict, NSError* error)\n{\n    if (!error)\n        NSLog(@\"Result: %@\", dict);\n    else\n        NSLog(@\"Error: %@\", error);\n}];\n    \n```\n    \n- With XML string as `NSString`\n\n```\n\nNSString* XMLString = @\"\"\n\"\u003cmessage\u003e\"\n\"    \u003cto\u003eA\u003c/to\u003e\"\n\"    \u003cfrom\u003eB\u003c/from\u003e\"\n\"    \u003ctitle \u003eFourth Title\u003c/title\u003e\"\n\"    \u003cbody\u003e\"\n\"          This is meessage body.\"\n\"        \u003cattachment\u003eAttachment 1\u003c/attachment\u003e\"\n\"    \u003c/body\u003e\"\n\"\u003c/message\u003e\";\n\n[EYXML2NSDictionary parseXMLString:XMLString completion:^(NSDictionary* dict, NSError* error)\n{\n    if (!error)\n        NSLog(@\"Result: %@\", dict);\n    else\n        NSLog(@\"Error: %@\", error);\n}];\n```\n\n## Examples\n### 1\n\n- Input\n\n```\n\u003cmessage\u003e\n    \u003cto\u003eA\u003c/to\u003e\n    \u003cfrom\u003eB\u003c/from\u003e\n    \u003ctitle anAttribute = 'a1' anotherAttribute = 'a2'\u003eFirst Title\u003c/title\u003e\n    \u003ctitle anAttribute = 'b1' anotherAttribute = 'b2'\u003eSecond Title\u003c/title\u003e\n    \u003ctitle \u003eThird Title\u003c/title\u003e\n    \u003ctitle \u003eFourth Title\u003c/title\u003e\n    \u003cbody\u003e\n          This is meessage body.\n        \u003cattachment\u003eAttachment 1\u003c/attachment\u003e\n        \u003cattachment\u003eAttachment 2\u003c/attachment\u003e\n       Yet more text is here.\n        \u003cattachment\u003eAttachment 3\u003c/attachment\u003e\n       This is the last text.\n    \u003c/body\u003e\n\u003c/message\u003e;\n```\n\n- Output\n\n```\n{\n  \"message\": {\n    \"body\": {\n      \"attachment\": [\n        \"Attachment 1\",\n        \"Attachment 2\",\n        \"Attachment 3\"\n      ],\n      \"-InnerText\": [\n        \"This is meessage body.\",\n        \"Yet more text is here.\",\n        \"This is the last text.\"\n      ]\n    },\n    \"to\": \"A\",\n    \"title\": [\n      {\n        \"-anAttribute\": \"a1\",\n        \"-InnerText\": \"First Title\",\n        \"-anotherAttribute\": \"a2\"\n      },\n      {\n        \"-anAttribute\": \"b1\",\n        \"-InnerText\": \"Second Title\",\n        \"-anotherAttribute\": \"b2\"\n      },\n      \"Third Title\",\n      \"Fourth Title\"\n    ],\n    \"from\": \"B\"\n  }\n}\n```\n\n### 2\n\n- Input\n\n```\n\u003ca attr=\"A\"\u003e\n    \u003cb attr1=\"B1-1\" attr2=\"B1-2\"\u003eBBBBB 1\u003c/b\u003e\n    XXXXX    \n    \u003cb attr=\"B2\"\u003e\n        BBBBB 2_0\n        \u003cc attr=\"C1\"\u003eCCCCC 1\u003c/c\u003e\n        BBBBB 2_1 \n        \u003cc attr=\"C2\"\u003e\n            CCCCC 2\n            \u003cd\u003e\n                DDDDD 1\n                \u003ce\u003e\n                    EEEEE 1\n                    \u003cf\u003eFFFFF\u003c/f\u003e\n                    EEEEE 2\n                \u003c/e\u003e\n                DDDDD 2\n            \u003c/d\u003e\u003c/c\u003e\n        \u003cc attr=\"C3\"\u003eCCCCC 3\u003c/c\u003e\n        BBBBB 2_2\n    \u003c/b\u003e\n    YYYYY\n    \u003cb\u003eBBBBB 3\u003c/b\u003e\n    ZZZZZ\n\u003c/a\u003e\n```\n\n- Output\n\n```\n{\n  \"a\": {\n    \"-attr\": \"A\",\n    \"b\": [\n      {\n        \"-attr2\": \"B1-2\",\n        \"-attr1\": \"B1-1\",\n        \"-InnerText\": \"BBBBB 1\"\n      },\n      {\n        \"-attr\": \"B2\",\n        \"-InnerText\": [\n          \"BBBBB 2_0\",\n          \"BBBBB 2_1\",\n          \"BBBBB 2_2\"\n        ],\n        \"c\": [\n          {\n            \"-attr\": \"C1\",\n            \"-InnerText\": \"CCCCC 1\"\n          },\n          {\n            \"-attr\": \"C2\",\n            \"-InnerText\": \"CCCCC 2\",\n            \"d\": {\n              \"e\": {\n                \"f\": \"FFFFF\",\n                \"-InnerText\": [\n                  \"EEEEE 1\",\n                  \"EEEEE 2\"\n                ]\n              },\n              \"-InnerText\": [\n                \"DDDDD 1\",\n                \"DDDDD 2\"\n              ]\n            }\n          },\n          {\n            \"-attr\": \"C3\",\n            \"-InnerText\": \"CCCCC 3\"\n          }\n        ]\n      },\n      \"BBBBB 3\"\n    ],\n    \"-InnerText\": [\n      \"XXXXX\",\n      \"YYYYY\",\n      \"ZZZZZ\"\n    ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkanyildiz%2Feyxml2nsdictionary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferkanyildiz%2Feyxml2nsdictionary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferkanyildiz%2Feyxml2nsdictionary/lists"}