operate on document tree, not text dump