|Well, since you spec'd batch, I'll give an approximation, which may or may not work (batch is not well suited to html or xml):|
::===== begin batchscript
@echo off & setlocal
for /f "tokens=*" %%a in (test1) do call :aa "%%a"
for /f "tokens=*" %%b in (%z%) do >>test2 echo %%~b
::===== end batch
Note this creates a second file but does not wipe out the original (ie: safety is in effect)
Here's a vbscript, which I recommend over batch, for handling this type of file:
'====== begin vbscript
'======= end vbscript
I glommed a bunch of steps together (vbs). If you want an un-glommed version, let me know (it is much easier to follow when it is portioned out).