Changed Parser to intended DOMParser. Moreover fixed an issue with tm-list to throw NPE or OutOfBounceExceptions after inserting new Tags at certain possitions. Algorithm works for simple cases - does not work as expected on real-case pages!