Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/JaapWijnen/swift-xml-parser


https://github.com/JaapWijnen/swift-xml-parser

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# swift-xml-parser

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FJaapWijnen%2Fswift-xml-parser%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/JaapWijnen/swift-xml-parser)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FJaapWijnen%2Fswift-xml-parser%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/JaapWijnen/swift-xml-parser)

A reversible XML parser powered by the excellent [swift-parsing][swift-parsing] package by [pointfree.co][pointfree]

## Getting Started

```swift
var input = """

"""

// The `XMLParser` type takes a single `Bool` parameter which determines the printing mode (with or without newlines/indentation)
let xml = try XMLParser(indenting: true).parse(input)
//XML(
// prolog: [
// "version": "1.0",
// "encoding": "utf-8"
// ],
// root: XML.Element(
// name: "root",
// attributes: [:],
// content: [
// .element(.init(name: "content", attributes: ["attribute1": "value"]))
// ]
// )
//)

let indentedPrintedXML = xmlParser(true).print(xml)
//
//
//
//

let flatPrintedXML = xmlParser(false).print(xml)
//
```

## License

This library is released under the MIT license. See [LICENSE](LICENSE) for details.

[swift-parsing]: https://github.com/pointfreeco/swift-parsing
[pointfree]: https://pointfree.co