extract tag instances from a document