A simple XMLRPC parser using SwiftParsec

SwiftXMLRPC

SwiftXMLRPC is a lightweight parser for XMLRPC.

Under the hood, this project uses SwiftParsec to parse XML.

All types support serialization and deserialization.

Usage

Parsing

// success(SwiftXMLRPC.XMLRPC.Response.params([SwiftXMLRPC.XMLRPC.Parameter.double(1.0)]))
print(
    XMLRPC.Response.deserialize(
        from: """
        <?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><double>1.0</double></value></param></params></methodResponse>
        """,
        sourceName: "https://examplewebsite.com/XMLRPC"
    )
)

Serialization

let xml = XMLRPC.Call(
    method: "example.method",
    params: [
        .struct(
            [ "first": .string("item"),
              "second": .array([.double(1e9)]),
              "third": .date(Date())
            ]
        )
    ]
).serialize()

Tests

Tests are writen with SwiftCheck and utilise roundtripping to catch bugs.

GitHub

View Github