Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Mozharovsky/XMLParser
A lightweight XMLParser for assembling and parsing XML values written for iOS 8+ in Swift 2.
https://github.com/Mozharovsky/XMLParser
Last synced: about 1 month ago
JSON representation
A lightweight XMLParser for assembling and parsing XML values written for iOS 8+ in Swift 2.
- Host: GitHub
- URL: https://github.com/Mozharovsky/XMLParser
- Owner: mozharovsky
- License: mit
- Created: 2015-08-29T19:04:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-13T06:48:42.000Z (almost 9 years ago)
- Last Synced: 2024-09-21T02:29:46.602Z (3 months ago)
- Language: Swift
- Size: 285 KB
- Stars: 74
- Watchers: 4
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift-cn - XMLParser - A lightweight XMLParser for assembling and parsing XML values written for iOS 8+ in Swift 2. (Libs / Data Management)
README
Overview
==========
* [Description](https://github.com/Mozharovsky/XMLParser#description)
* [Requirements](https://github.com/Mozharovsky/XMLParser#requirements)
* [Installation](https://github.com/Mozharovsky/XMLParser#installation)
* [Usage](https://github.com/Mozharovsky/XMLParser#usage)
* [Author](https://github.com/Mozharovsky/XMLParser#author)
* [License](https://github.com/Mozharovsky/XMLParser#license)Description
==========
XMLParser lets you convert a pure Swift dictionary into XML string and vice versa.Requirements
==========
* Swift 2 (Xcode 7+)
* iOS 8+
* ARCInstallation
==========###Cocoa Pods
```ruby
pod 'XMLParser', '~> 1.0'
```Usage
==========####Parsing an XML string from a Dictionary
```swift
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 = "\n"
let result = XMLParser.sharedParser.encode(body, header: header)
print(result)
```####Result
```XMLRSA
getOrder
iOS 9
2015-08-29 12:00:00
iPhone 6 Plus
```
####Associated tags
E.g. `0`
```swift
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
```XML0
1
205```
==========
####Extracting data from an XML converted string
```swift
let convertedString = "getOrder2015-08-29 12:00:00iPhone 6 PlusiOS 9RSA"
let result = XMLParser.sharedParser.decode(convertedString)
print(result)
```####Result
```swift
[
type: [getOrder, RSA],
device_os_version: [iOS 9],
date: [2015-08-29 12:00:00],
device_name: [iPhone 6 Plus]
]
```Author
==========
Eugene Mozharovsky ([@DottieYottie](https://twitter.com/DottieYottie))[License](https://github.com/Mozharovsky/XMLParser/blob/master/LICENSE)
==========