问题
I'm trying to create an XMPP library (and later a server) from scratch in Go (although the language itself is irrelevant) as a means to learn what I can about the XMPP protocol and server software development in general.
As many of you know, XMPP is messaging protocol based on XML that depends on an enormous amount of short but frequent XML streams. I'm thinking that for such applications an event based XML parser should be better because I won't need DOM and all that (correct me if I'm wrong). Please keep in mind that this library is intended for servers so there might be many instances run at once;
Which one of the two has better performance and memory usage for that use case, libxml2 or expat?
回答1:
There is a whole project devoted to answering the question of XML performance called XML Benchmark.
The short answer, in my opinion, is to use libxml2, but I have other considerations beyond pure performance, such as platform availability. That said, it is generally faster than expat according to the latest numbers, though it's fairly close in the great scheme of things.
And yes, you want to use the SAX parser, not the DOM parser.
来源:https://stackoverflow.com/questions/3714184/libxml2-vs-expat-for-an-xmpp-server