A lightweight xml parser written in pure swift

What's New




Language Issues License Build Queen

Lightweight XML parsing in pure Swift 3. No Foundation. No dependencies.

SwiftXML doesn’t wrap anything. It parses XML directly, character by character. And the API is simple and easy to use. In fact, it exposes just two objects — a protocol and a function:

protocol Parser
    func handle_data(data:[UnicodeScalar])
    func handle_starttag(name:String, attributes:[String: String])
    func handle_startendtag(name:String, attributes:[String: String])
    func handle_endtag(name:String)
    func error(_:String, line:Int, column:Int)
func parse(_:String, parser:Parser)

SwiftXML will tokenize your XML string into tags and data. It does not build any tree structures; that is for you to implement. Nor does it read files from disk into memory; that is for the Swift standard library to implement (hint hint @ Swift standard library devs).

See the swiftxmlTests.swift file for a usage example, if you are still confused.


  • Swift Tools 3.1.0
View More Packages from this Author


  • None
Last updated: Sat Dec 02 2023 19:24:25 GMT-1000 (Hawaii-Aleutian Standard Time)