XMLDecoder for Swift.
- iOS 8.0+
- Xcode 9.0+
- Swift 4.0+
To integrate XMLDecoder into your Xcode project using Carthage, specify it in your Cartfile
:
github "uny/XMLDecoder"
You can use XMLDecoder like JSONDecoder:
struct Object {
let string: String
let int: Int
}
let data = "<root><string>string</string><int>100</int></root>".data(using: .utf8)!
let decoder = XMLDecoder()
do {
let object = try decoder.decode(Object.self, from: data)
print(object)
} catch let error {
// ...
}
XMLDecoder currently does not support attributes.