title: How can I use batch to output a block of text using variables read in from a txt file?
body: <p>TIA for any help or advice. </p>
  
  <p>I have a requirement to import over 10k connection strings into MTPuTTY and the only way to do so is via the import function using an xml. </p>
  
  <p>I have a connectionstrings.txt which has a list of all the strings and I'll be using each value as an entry several times in each block of text. </p>
  
  <p>So the strings.txt file would look like;</p>
  
  <p>username1@servername1 
  username1@servername2
  username2@servername1
  username2@servername2
  etc</p>
  
  <p>The batch file should take each of these as a variable and enter them into the block before outputting the block to an xml.</p>
  
  <p>The standard block should look like this; </p>
  
  <pre><code>&lt;Node Type="1"&gt;
              &lt;SavedSession&gt;username1@servername1 &lt;SavedSession&gt;
              &lt;DisplayName&gt;username1@servername1 &lt;/DisplayName&gt;
              &lt;ServerName&gt;username1@servername1 &lt;/ServerName&gt;
              &lt;PuttyConType&gt;0&lt;/PuttyConType&gt;
              &lt;Port&gt;22&lt;/Port&gt;
              &lt;UserName&gt;&lt;/UserName&gt;
              &lt;Password&gt;&lt;/Password&gt;
              &lt;PasswordDelay&gt;0&lt;/PasswordDelay&gt;
              &lt;CLParams&gt;-load username1@servername1  "username1@servername1 " -P 22&lt;/CLParams&gt;
              &lt;ScriptDelay&gt;0&lt;/ScriptDelay&gt; ) 
  </code></pre>
  
  <p>So far I've tried to compile an IF statement using %%I as the variable and building the block with that but I get various errors such as Echo not expected. I assume I'm being daft and missing basic syntax. </p>
  
  <pre><code>FOR /F %%i in (connection strings.txt) echo ( 
  
   &lt;Node Type="1"&gt;
              &lt;SavedSession&gt;%%i&lt;/SavedSession&gt;
              &lt;DisplayName&gt;%%i&lt;/DisplayName&gt;
              &lt;ServerName&gt;%%i&lt;/ServerName&gt;
              &lt;PuttyConType&gt;0&lt;/PuttyConType&gt;
              &lt;Port&gt;22&lt;/Port&gt;
              &lt;UserName&gt;&lt;/UserName&gt;
              &lt;Password&gt;&lt;/Password&gt;
              &lt;PasswordDelay&gt;0&lt;/PasswordDelay&gt;
              &lt;CLParams&gt;-load %%i "%%i" -P 22&lt;/CLParams&gt;
              &lt;ScriptDelay&gt;0&lt;/ScriptDelay&gt; ) &gt;&gt; connection strings.xml
  </code></pre>
  
  <p>Ideally, it'd be great if the batch could generate separate XML files per user if that's possible?</p>