Popularity
1.9
Declining
Activity
0.0
Stable
75
3
7

Code Quality Rank: L4
Programming language: Swift
Tags: Data Management     XML    
Latest version: v1.0

XMLParser alternatives and similar libraries

Based on the "XML" category

Do you think we are missing an alternative of XMLParser or a related project?

Add another 'XML' Library

README

Overview

Description

XMLParser lets you convert a pure Swift dictionary into XML string and vice versa.

Requirements

  • Swift 2 (Xcode 7+)
  • iOS 8+
  • ARC

Installation

Cocoa Pods

pod 'XMLParser', '~> 1.0'

Usage

Parsing an XML string from a Dictionary

let body = [
    "request" : [
        "meta" : [
            "type" : "getOrder",
            "date" : "2015-08-29 12:00:00",
            "device_name" : "iPhone 6 Plus",
            "device_os_version" : "iOS 9"
        ]
    ],

    "encryption" : [
        "type" : "RSA"
    ]
]

let header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
let result = XMLParser.sharedParser.encode(body, header: header)
print(result)

Result

<?xml version="1.0" encoding="UTF-8"?>
<encryption>
   <type>RSA</type>
</encryption>
<request>
   <meta>
      <type>getOrder</type>
      <device_os_version>iOS 9</device_os_version>
      <date>2015-08-29 12:00:00</date>
      <device_name>iPhone 6 Plus</device_name>
   </meta>
</request>

Associated tags

E.g. <td class='achievements'>0</td>

let data = [
    "tr" : [
        XMLTag(header: "td", name: "class", value: "num") : 1,
        XMLTag(header: "td", name: "class", value: "achievments") : 0,
        XMLTag(header: "td", name: "class", value: "sum") : 205
    ]
]

let result = XMLParser.sharedParser.encode(data)
print(result)

Result

<tr>
   <td class='achievments'>0</td>
   <td class='num'>1</td>
   <td class='sum'>205</td>
</tr>

==========

Extracting data from an XML converted string

let convertedString = "<request><meta><type>getOrder</type><date>2015-08-29 12:00:00</date><device_name>iPhone 6 Plus</device_name><device_os_version>iOS 9</device_os_version></meta></request><encryption><type>RSA</type></encryption>"
let result = XMLParser.sharedParser.decode(convertedString)
print(result)

Result

[
  type: [getOrder, RSA], 
  device_os_version: [iOS 9], 
  date: [2015-08-29 12:00:00], 
  device_name: [iPhone 6 Plus]
]

Author

Eugene Mozharovsky (@DottieYottie)

License


*Note that all licence references and agreements mentioned in the XMLParser README section above are relevant to that project's source code only.