in reply to delete and substitute

Why aren't you using a module for parsing XML?