File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -393,6 +393,27 @@ This will encode value `Book(id: 42)` as `<Book id="42"><id>42</id></Book>`. It
393393This feature is available starting with XMLCoder 0.13.0 and was implemented
394394by [ @bwetherfield ] ( https://github.com/bwetherfield ) .
395395
396+ ### XML Headers
397+
398+ You can add an XML header and/or doctype when encoding an object by supplying it to the ` encode ` function.
399+ These arguments are both optional, and will only render when explicitly provided.
400+
401+ ``` swift
402+ struct User : Codable {
403+ @Element var username: String
404+ }
405+
406+ let data = try encoder.encode (
407+ User (username : " Joanis" ),
408+ withRootKey : " user" ,
409+ header : XMLHeader (version : 1.0 , encoding : " UTF-8" ),
410+ doctype : .system (
411+ rootElement : " user" ,
412+ dtdLocation : " http://example.com/myUser_v1.dtd"
413+ )
414+ )
415+ ```
416+
396417## Installation
397418
398419### Requirements
@@ -425,7 +446,7 @@ easy as adding it to the `dependencies` value of your `Package.swift`.
425446
426447``` swift
427448dependencies: [
428- .package (url : " https://github.com/CoreOffice/XMLCoder.git" , from : " 0.14 .0" )
449+ .package (url : " https://github.com/CoreOffice/XMLCoder.git" , from : " 0.15 .0" )
429450]
430451```
431452
@@ -489,7 +510,7 @@ $ brew install carthage
489510Inside of your ` Cartfile ` , add GitHub path to ` XMLCoder ` :
490511
491512``` ogdl
492- github "CoreOffice/XMLCoder" ~> 0.14 .0
513+ github "CoreOffice/XMLCoder" ~> 0.15 .0
493514```
494515
495516Then, run the following command to build the framework:
You can’t perform that action at this time.
0 commit comments