title: Capture dynamic value from jmeter request body and correlate back in the same
body: <p>Working on the Jmeter to create load script for an inbound call. When the application receives the call Jmeter captured the below as POST request body:</p>
  
  <pre><code>5|0|21|https://d50.eng.domain.com:1050/newgenmashup/v1/mashup/|1D4E8B05B21570719C10066C4E15360C|com.contactual.client.SFService|triggerEvent|java.lang.String|com.contactual.client.model.GenericXmlData|java.util.TreeMap|tenant~~pagent2|com.contactual.client.model.GenericXmlData/2918165779||353-726-6515|no|offered|PHONE|in|563|PavanInboundQueue|1|465|&lt;UserData&gt;
  &lt;param name = "@pri"&gt;&lt;![CDATA[100]]&gt;&lt;/param&gt;
  &lt;param name="callingName"&gt;&lt;![CDATA[ 1234567366]]&gt;&lt;/param&gt;
  &lt;param name="cha"&gt;&lt;![CDATA[3537266515]]&gt;&lt;/param&gt;
  &lt;param name="channelName"&gt;&lt;![CDATA[353-726-6515]]&gt;&lt;/param&gt;
  &lt;param name="cnt"&gt;&lt;![CDATA[0]]&gt;&lt;/param&gt;
  &lt;param name="con"&gt;&lt;![CDATA[0]]&gt;&lt;/param&gt;
  &lt;param name="med"&gt;&lt;![CDATA[T]]&gt;&lt;/param&gt;
  &lt;param name="otim"&gt;&lt;![CDATA[1550070210]]&gt;&lt;/param&gt;
  &lt;param name="pho"&gt;&lt;![CDATA[ 1234567366]]&gt;&lt;/param&gt;
  &lt;param name="phoneNum"&gt;&lt;![CDATA[ 1234567366]]&gt;&lt;/param&gt;
  &lt;param name="priority"&gt;&lt;![CDATA[50]]&gt;&lt;/param&gt;
  &lt;param name="que"&gt;&lt;![CDATA[vcclondon~~queue~~phone~~563]]&gt;&lt;/param&gt;
  &lt;param name="queueDirection"&gt;&lt;![CDATA[in]]&gt;&lt;/param&gt;
  &lt;param name="tenantName"&gt;&lt;![CDATA[vcclondon]]&gt;&lt;/param&gt;
  &lt;param name="tenantRecServer"&gt;&lt;![CDATA[d50]]&gt;&lt;/param&gt;
  &lt;param name="tenantSkillName"&gt;&lt;![CDATA[PavanInboundQueue]]&gt;&lt;/param&gt;
  &lt;param name="tim"&gt;&lt;![CDATA[1550070210]]&gt;&lt;/param&gt;
  &lt;param name="tok"&gt;&lt;![CDATA[465]]&gt;&lt;/param&gt;
  &lt;param name="queuedTime"&gt;&lt;![CDATA[0]]&gt;&lt;/param&gt;
  &lt;param name="ani"&gt;&lt;![CDATA[ 1234567366]]&gt;&lt;/param&gt;
  &lt;param name="interaction_guid"&gt;&lt;![CDATA[int-168e76257e3-r5tEbRqwNR7hBd7jmuvwnsxG9-phone-00-vcclondon]]&gt;&lt;/param&gt;
  &lt;param name="transaction_id"&gt;&lt;![CDATA[465]]&gt;&lt;/param&gt;
  &lt;param name="notes"&gt;&lt;![CDATA[]]&gt;&lt;/param&gt;
  &lt;param name="callbackTimeMs"&gt;&lt;![CDATA[]]&gt;&lt;/param&gt;
  &lt;param name="ctl_userdata"&gt;&lt;![CDATA[[doNotCallSelected\!false][donotcallSelected\!false]]]&gt;&lt;/param&gt;
  &lt;/UserData&gt;|java.util.TreeMap/1575826026|1|2|3|4|3|5|6|7|8|9|0|0|0|0|10|0|0|0|10|0|11|0|12|0|13|10|0|10|1|0|0|0|14|15|16|17|18|10|10|0|19|20|21|0|0|
  </code></pre>
  
  <p>I would like to retrieve each param value and correlate. Stored above body data into string.</p>
  
  <pre><code>String requestBody = sampler.getArguments();
  </code></pre>
  
  <p>Used the xmlslurper to navigate to treemap. Example: I am trying to extract the interaction id using below snippet.</p>
  
  <pre><code>def UserData = new XmlSlurper().parseText(requestBody)
  def interaction_guid = UserData.param[20].@name
  </code></pre>
  
  <p>Expected: I would like to correlate all values. Because, no value is user input data.</p>
  
  <p>Actual is: </p>
  
  <pre><code>2019-02-18 12:14:33,111 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223 script, JSR223 PreProcessor
  javax.script.ScriptException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
  at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:324) ~[groovy-all-2.4.15.jar:2.4.15]
  at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.15.jar:2.4.15]
  at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_151]
  at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:221) ~[ApacheJMeter_core.jar:5.0 r1840935]
  at org.apache.jmeter.modifiers.JSR223PreProcessor.process(JSR223PreProcessor.java:44) [ApacheJMeter_components.jar:5.0 r1840935]
  at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:935) [ApacheJMeter_core.jar:5.0 r1840935]
  at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:537) [ApacheJMeter_core.jar:5.0 r1840935]
  at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) [ApacheJMeter_core.jar:5.0 r1840935]
  at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) [ApacheJMeter_core.jar:5.0 r1840935]
  at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
  Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
  at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
  at groovy.util.XmlSlurper.parse(XmlSlurper.java:205) ~[groovy-all-2.4.15.jar:2.4.15]
  at groovy.util.XmlSlurper.parse(XmlSlurper.java:258) ~[groovy-all-2.4.15.jar:2.4.15]
  at groovy.util.XmlSlurper.parseText(XmlSlurper.java:284) ~[groovy-all-2.4.15.jar:2.4.15]
  at groovy.util.XmlSlurper$parseText.call(Unknown Source) ~[?:?]
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-all-2.4.15.jar:2.4.15]
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-all-2.4.15.jar:2.4.15]
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) ~[groovy-all-2.4.15.jar:2.4.15]
  at Script26.run(Script26.groovy:17) ~[?:?]
  at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) ~[groovy-all-2.4.15.jar:2.4.15]
  ... 9 more
  </code></pre>
  
  <p>Can you please help me in extracting each param, correlate and put back in the in the same POST request.</p>