XMLCoder Documentation

Structure Element​And​Attribute

@propertyWrapper
public struct ElementAndAttribute<Value>: XMLElementAndAttributeProtocol  

Property wrapper specifying that a given property should be decoded from either an XML element or an XML attribute. When encoding, the value will be present as both an attribute, and an element.

For example, this type

struct Book: Codable {
    @ElementAndAttribute var id: Int
}

will encode value Book(id: 42) as <Book id="42"><id>42</id></Book>. It will decode both <Book><id>42</id></Book> and <Book id="42"></Book> as Book(id: 42).

%45 ElementAndAttribute ElementAndAttribute XMLElementAndAttributeProtocol XMLElementAndAttributeProtocol ElementAndAttribute->XMLElementAndAttributeProtocol Codable Codable ElementAndAttribute->Codable

Conforms To

Codable

Initializers

init(_:​)

public init(_ wrappedValue: Value)  

Properties

wrapped​Value

public var wrappedValue: Value