https://github.com/elihwyma/pugiswift
Blazing fast XML Parser in Swift for all platforms
https://github.com/elihwyma/pugiswift
concurrency linux swift vapor xml
Last synced: 12 months ago
JSON representation
Blazing fast XML Parser in Swift for all platforms
- Host: GitHub
- URL: https://github.com/elihwyma/pugiswift
- Owner: elihwyma
- License: apache-2.0
- Created: 2024-10-29T14:13:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-06T17:31:33.000Z (12 months ago)
- Last Synced: 2025-07-06T18:37:38.438Z (12 months ago)
- Topics: concurrency, linux, swift, vapor, xml
- Language: C++
- Homepage: https://swiftpackageindex.com/elihwyma/PugiSwift/0.3.0/documentation/pugiswift
- Size: 375 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# PugiSwift
[](https://swiftpackageindex.com/elihwyma/PugiSwift)
[](https://swiftpackageindex.com/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.
The current version of pugixml bundled is [1.14](https://github.com/zeux/pugixml/releases/tag/v1.14).
pugixml is licensed under the MIT license and a copy can be found [here](Sources/pugixml/LICENSE.md).
## Benchmarking
PugiSwift has been benchmarked among other popular alterative Swift packages. The code for this benchmark is available [in this repo](https://github.com/elihwyma/PugiSwiftComparisons). The test was in Release mode with the debugger turned off. Comparisons were made against [Fuzi](https://github.com/cezheng/Fuzi.git) and [XMLCoder](https://github.com/CoreOffice/XMLCoder.git).
```mermaid
xychart-beta
title "Parses per second of 212kb file"
x-axis "Programs" ["PugiSwift", "Fuzi", "XMLCoder"]
bar [757, 207, 54]
```
## Example Usage
```swift
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 =
"""
Paul Koch
17
"""
do {
let records = try Records(from: str)
print(records)
} catch {
print("Error: \(error.localizedDescription)")
}
```