Add a line in XML using batch file before a tag
<p>I have an XML file of the type</p>

<pre><code>....
&lt;sometag&gt;
&lt;tag attr_name1="long filename1" /&gt;
&lt;tag attr_name2="long filename2" /&gt;
....
&lt;/sometag&gt;
....
</code></pre>

<p>Before <code>&lt;/sometag&gt;</code> I want to add <code>&lt;tag attr_name="long filename" /&gt;</code> so far the code in my Batch Script for Windows is:</p>

<pre><code>@echo off
setlocal enableDelayedExpansion
set "newValue=^&lt;tag attr_name="long filename" /^&gt;
set newline=^&amp; echo.
type "File.xml"|replace "(&lt;/tag&gt;)" "!newValue!$1" &gt;dupFile.xml
move /y "dupFile.xml" "File.xml"
</code></pre>

<p>I get "<code>Path not found - &lt;/tag&gt;</code>" and File.xml contains "No Files Replaced". I know its not best practice to edit XML from batch file but can't use third party executables unfortunately. Can someone please help with where I'm going wrong?</p>

<p>Also I've checked <a href="https://stackoverflow.com/questions/17054275/changing-tag-data-in-an-xml-file-using-windows-batch-file">the thread</a> about changing data between tags in XML using batch file, when I use the suggested code there and alter to my requirement i get the above error.</p>