I built a pure Swift XML parser (no DTD, external entity, transcoding support) at https://github.com/compnerd/xylem. Some informal testing indicated that it is faster than libxml2 and xmloxide, a rust port of libxml2.
GitHub - compnerd/xylem: XML Parsing Library

XML Parsing Library. Contribute to compnerd/xylem development by creating an account on GitHub.

GitHub
@compnerd Sigh, a tad too late for me, I would have just used that :-) (I just did a similar Expat variant for my own needs, I did some very heavy perf testing and in many things its almost twice as fast as Expat)
@helge I should add, that depending on the workload, I did see similar results. libxml2 has a long time horizon to have been tweaked, and there are places where it is already entirely optimal.
@compnerd One would have to check the asm but I suspect the reason why Swift is actually faster (which I didn’t anticipate given the maturity of both Expat and libxml2) is that the optimizer can’t be as aggressive in C.
@helge yes, as a concrete example is alias analysis. Swift is just helping the compiler. But expat and libxml2 have a long history of people improving performance so, it’s a huge deal to meet or beat at first pass.