XMLCoder
XMLCoder copied to clipboard
Easy XML parsing using Codable protocols in Swift
I wonder whether XMLCoder can be used / improved to handle SOAP documents. SOAP documents make excessive use of XML namespaces, e.g. consider the following SOAP document example: ```xml operator...
```swift // Model class Bar:Codable, DynamicNodeEncoding { enum CodingKeys: String, CodingKey { case id } static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding { switch key { case CodingKeys.id: return .attribute...
```swift // Model class Foo:Object, Codable, DynamicNodeEncoding { enum CodingKeys: String, CodingKey { case id case numbers = "number" } static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding { switch key...
Let's say I have this simple XML: ```swift let sample = """ Peter Ent Atlanta, GA """ ``` And I wish to decode it into the following Swift classes: ```swift...
Lets take your book example: ```xml 123 Cat in the Hat Kids Wildlife ``` If we switch it around like this, so that the order of elements no longer follows...
Property wrappers could be a great fit to replace the `DynamicNodeEncoding` API. E.g. ```swift struct Tag: Codable { @Element var element: String @Attribute var attribute: String } ``` would be...
I got an XML with dates formatted with ISO8061, but the XMLCoder can't decode them. I've tried to user the ISO8601DateFormatter and, by itself, it does the job well. But...
If I instantiate a Codable object, is there way to decode into that specific instance, rather than supplying the Type? try? decoder.decode(into: myCodableObject) Regards Peter
Hi, I'm trying to parse the following XML: ` ` Into this struct: `struct Model: Codable { let string: String let int: Int let bool: Bool enum CodingKeys: String, CodingKey...
Seems like ``` 456 ``` **decoder.shouldProcessNamespaces** doesn't work for DynamicNodeDecoding attributes: ``` func testParse() { struct Foo: Codable, DynamicNodeDecoding { let name, id: String let value: String enum CodingKeys: String,...