Contents

elihwyma/pugiswift

PugiSwift is a Swift wrapper around the C++ library [pugixml](https://github.com/zeux/pugixml). The aim is to provide a fast way to parse XML with Swift on both Apple platforms and on the server with Vapor.

Benchmarking

PugiSwift has been benchmarked among other popular alterative Swift packages. The code for this benchmark is available in this repo. The test was in Release mode with the debugger turned off. Comparisons were made against Fuzi and XMLCoder.

xychart-beta
    title "Parses per second of 212kb file"
    x-axis "Programs" ["PugiSwift", "Fuzi", "XMLCoder"]
    bar [757, 207, 54]

Example Usage

import Foundation
import PugiSwift

@Node struct Records {
    @Attribute let value: String
    @Element(childrenCodingKey: "record") let records: [Record]
}

@Node struct Record {
    let name: String
    let list: Int
}

let str =
"""

<records value="Hello World">
    <record>
        <name>Paul Koch</name>
        <list>17</list>
    </record>
</records> 
"""

do {
    let records = try Records(from: str)
    print(records)
} catch {
    print("Error: \(error.localizedDescription)")
}

Package Metadata

Repository: elihwyma/pugiswift

Default branch: main

README: README.md