title: for loop in groovy for string with concatenation
body: <p>I have string like <code>Color=Blue|Size=M|Style=simpleStyle</code> and it need to be converted as like below by using groovy.</p>
  
  <pre><code>&lt;Item&gt;
        &lt;comp&gt;
          &lt;name&gt;Color&lt;/name&gt;
          &lt;value&gt;Blue&lt;/value&gt;
        &lt;/comp&gt;
        &lt;comp&gt;
          &lt;name&gt;Size&lt;/name&gt;
          &lt;value&gt;M&lt;/value&gt;
        &lt;/comp&gt;
        &lt;comp&gt;
          &lt;name&gt;Style&lt;/name&gt;
          &lt;value&gt;simpleStyle&lt;/value&gt;
        &lt;/comp&gt;
  &lt;/Item&gt;
  </code></pre>
  
  <p>I have written groovy for loop something like below. I believe i am trying it in bit harder way. Is there any simple way to produce above XML using Groovy ?</p>
  
  <pre><code>for (int i = 0; StrRelationshipDetails.toString().contains('|'); i++) {
      println StrRelationshipDetails.toString()
  
      def StrPair = new StringBuilder(StrRelationshipDetails.substring(0, StrRelationshipDetails.indexOf('|')))
      def StrName = new StringBuilder(StrPair.substring(0, StrPair.indexOf('=')))
      def StrValue = new StringBuilder(StrPair.substring(StrPair.indexOf('=')+1, StrPair.size()))
  
      StrRelationshipDetails = StrRelationshipDetails.substring(StrRelationshipDetails.indexOf('|')+1, StrRelationshipDetails.size())
  }
      println StrRelationshipDetails.toString()
  </code></pre>