How your XML parser can detect encoding?

I've just fined a tiny article which describe how XML parsers detect document encoding. I hope you already know this but it always good to read it again. In a few words, parsers use the first document characters which are the same in all xml document and try different ways to read them and evaluate encoding.
http://www.xfront.com/specifying-encoding/index.html