Skip to content

Commit 1b5011b

Browse files
authored
Update README.md
1 parent c438dad commit 1b5011b

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,27 @@ This will encode value `Book(id: 42)` as `<Book id="42"><id>42</id></Book>`. It
393393
This feature is available starting with XMLCoder 0.13.0 and was implemented
394394
by [@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
427448
dependencies: [
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
489510
Inside 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

495516
Then, run the following command to build the framework:

0 commit comments

Comments
 (0)