traverse a domdocument in a pre-order way