'Insert text file contents (line by line) into XML using batch script

I have below Unix shell script for inserting text file contents into an XML. I'm new to windows batch scripting. Can you suggest similar code in batch script to achieve the same ?

#Insert the contents of a text file into XML
a=0
rm $path/output.xml > /dev/null 2>&1
while IFS= read F1line
do
        b=`echo "$F1line" | tr -d " "`
        #echo $b
        if test "$b" == '<search string1>'
        then
                echo "$F1line" >> $path/output.xml
                while IFS= read F2line
                do
                echo "$F2line" >> $path/output.xml
                done < $path/insert.txt
                a=1
        fi

        if test $a -eq 1
        then
                if test "$b" = "<search string2>"
                then
                        #echo "$F1line" >> $path/output.xml
                        a=0
                else
                        continue
                fi
        fi

        echo "$F1line" >> $path/output.xml

done < $path/input.xml

echo "XML updated successfully"

Basically, the script starts writing line by line into output.xml (from input.xml) and when a specific string1 occurs, it starts inserting text file contents into xml and it continues to check for string2 and write remaining lines of input.xml into output.xml.

Regards, Sid



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source