title: JMeter modifying output to file from XML Stream
body: <p>I'm attempting to write a JMeter script which after receiving and XML response from a server, extracts a string from it on the fly (drops the first part of the response) and writes it to a file.</p>
  
  <p>Currently I use a <code>Save Response Data</code> to write to <code>ChannelData_UAT_1</code> (filename).  All good, it writes happily.</p>
  
  <p>Then I add a <code>BSF PreProcessor</code> <strong>BEFORE</strong> it, and use javascript to try and extract the string.  It's a bunch of XML tags, I want everything from "<code>&lt;Markets&gt;</code>" onwards.</p>
  
  <p>I use:</p>
  
  <pre><code>function extract_markets(str)
  {
      marketIndex = str.indexOf("&lt;Markets");
      __log(marketIndex);
      length = str.length;
      marketString = str.substring(markeIndex, length-1);
      return str;
  }
  
  vars.put('ChannelData_UAT_1', extract_markets(vars.get('ChannelData_UAT_1')));
  </code></pre>
  
  <p>As far as I can tell, <code>ChannelData_UAT_1</code> is the variable the data is in. However this is only mentioned in the <code>Save Response Data</code>.  But I can't do it afterwards otherwise it'll have already written to the file.</p>
  
  <p>The current performance is for it to receive the response and write to the file.  No filtering is done - as if my javascript didn't exist.</p>
  
  <p>Anything small or obvious that I've missed? Suggestions?</p>