Swiftpack.co - Package - adam-fowler/xml-encoder

XML Encoder

This is a XML encoder and decoder that integrates with the Swift Codable system. It can create an XML tree from a Codable class or create Codable classes from an XML tree. The encoder uses its own XML classes which fairly closely follow the format of the XMLNode classes found in the macOS and Linux Foundation classes.

Using the classes

The basic method for saving a XML file from a Codable class or struct is as follows

let xml = try XMLEncoder().encode(codable)
let xmlString = xml.xmlString

And to create a Codable class from xml data

let xmlDocument = try XML.Document(data: data)
let codable = try XMLDecoder().decode(Codable.self, from: xmlDocument.rootElement) 

Reference documentation can be found here.

Github

link
Stars: 2

Dependencies

Used By

Total: 0

Releases

v0.3.0 - 2019-08-08 20:44:44

  • Changed to using Apache 2.0 license
  • Don't output newlines if flagged to ignore whitespace
  • Don't encode single or double speech marks when outputting XML text nodes

v0.2.0 - 2019-07-19 16:02:29

  • Add options for parsing and outputting XML (preserve whitespace, compacted empty nodes, CDATA)
  • Added calculated vars index and level to XML.Node

v0.1.0 - 2019-07-13 20:00:08

Initial version

  • includes XML representation
  • Encode codable to XML
  • Decode xml to codable