This paper designs a novel method for data mining on XML streams, which consists of three phases. Each XML document is first transformed into a sequence. After that, a compact tree structure is built to compress the huge amount of subsequences (subtrees) and keep their frequencies. Finally, an efficient algorithm for mining all frequent patterns is provided. Moreover, it can also be applied for mining maximal patterns. The experimental results show that the proposed method performs well in two different kinds of datasets. Its efficiency on sparse data is better, while the accuracy of its returned results on dense data is better when a few errors are tolerable.