CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
795 stars 107 forks source link

Update XMLCoderElement.swift #230

Closed ThePredators closed 2 years ago

ThePredators commented 2 years ago

The existing implementation was wrong, when the element is empty we set an empty xml tag. We should simply not set it.

Example : structure Test { var Title: String, var description: String? }

In this case calling encode() function like this : let xmlEncoder = XMLEncoder() xmlEncoder.keyEncodingStrategy = XMLEncoder.KeyEncodingStrategy.capitalized let data = try xmlEncoder.encode(self, withRootKey:"Test")

Result in : `

"Test"

`

The update I made will simply return this instead of an xml string containing an empty element : `

"Test"

`

MaxDesiatov commented 2 years ago

Hi @ThePredators, would you be interested to move this PR forward? I'm cleaning up the repository, and if this PR is abandoned and outdated, I'm inclined to close it. Thanks!

MaxDesiatov commented 2 years ago

I'm closing this PR as abandoned, please feel free to reopen otherwise.