title: Convert XML to specific JSON structure with powershell
body: <p>Need a help on converting an xml to a specific json structure.
  XML would look like this,</p>
  
  <pre><code>&lt;DataGrid&gt; 
  &lt;DataRow&gt;
      &lt;RowID&gt;1&lt;/RowID&gt;
      &lt;Date&gt;26/10/2014&lt;/Date&gt;
      &lt;Owner&gt;ABC Company&lt;/Owner&gt;        
      &lt;Make&gt;Mitsubishi&lt;/Make&gt;
      &lt;Model_Family&gt;Lancer&lt;/Model_Family&gt;
      &lt;Submodel&gt;Lancer 2.0 GSR Hatch CVT&lt;/Submodel&gt;
      &lt;Origin/&gt;
      &lt;CC_Rating&gt;1997&lt;/CC_Rating&gt;
      &lt;Weight&gt;2000&lt;/Weight&gt; 
  &lt;/DataRow&gt; 
  &lt;DataRow&gt;
      &lt;RowID&gt;2&lt;/RowID&gt;
      &lt;Date&gt;26/10/2014&lt;/Date&gt;
      &lt;Owner&gt;ABC Company&lt;/Owner&gt;        
      &lt;Make&gt;Mazda&lt;/Make&gt;
      &lt;Model_Family&gt;Axela&lt;/Model_Family&gt;
      &lt;Submodel/&gt;
      &lt;Origin&gt;Japan&lt;/Origin&gt;
      &lt;CC_Rating&gt;1497&lt;/CC_Rating&gt;
      &lt;Weight/&gt; 
  &lt;/DataRow&gt;
   &lt;DataRow&gt;
      &lt;RowID&gt;3&lt;/RowID&gt;
      &lt;Date&gt;26/10/2014&lt;/Date&gt;
      &lt;Owner&gt;Test Company&lt;/Owner&gt;        
      &lt;Make&gt;Kia&lt;/Make&gt;
      &lt;Model_Family&gt;Sorento&lt;/Model_Family&gt;
      &lt;Submodel/&gt;
      &lt;Origin&gt;Korea&lt;/Origin&gt;
      &lt;CC_Rating&gt;2200&lt;/CC_Rating&gt;
      &lt;Weight&gt;2500&lt;Weight&gt; 
  &lt;/DataRow&gt;
  &lt;DataRow&gt;
      &lt;RowID&gt;4&lt;/RowID&gt;
      &lt;Date&gt;26/10/2014&lt;/Date&gt;
      &lt;Owner&gt;Test Company&lt;/Owner&gt;        
      &lt;Make&gt;Nissan&lt;/Make&gt;
      &lt;Model_Family&gt;Pathfinder&lt;/Model_Family&gt;
      &lt;Submodel&gt;SUV&lt;Submodel&gt;
      &lt;Origin&gt;Japan&lt;/Origin&gt;
      &lt;CC_Rating&gt;2000&lt;/CC_Rating&gt;
      &lt;Weight&gt;2000&lt;Weight&gt; 
  &lt;/DataRow&gt;
  </code></pre>
  
  <p>
   There can be one or more files in above format, my requirement is to read all those files and group them by Owner and call a REST web service by converting those object to JSON. Required JSON format will be as follows.</p>
  
  <pre><code>{
  "batches": [
      {
          "Owner": "ABC Company",
          "Date": "2014-10-26",
          "Vehicles": [
              {                    
                  "Make": "Mitsubishi",
                  "ModelFamily": "Lancer",
                  "SubModel": "Lancer 2.0 GSR Hatch CVT",
                  "Origin": null
                  "CcRating": "1997",
                  "Weight": "2000"                    
              },
              {                   
                  "Make": "Mazda",
                  "ModelFamily": "Axela",
                  "SubModel": null,
                  "Origin": "Japan",
                  "CcRating": "1497",
                  "Weight": null                   
              }
          ]
      },
      {
          "Owner": "Test Company",
          "Date": "2014-10-26",
          "Vehicles": [
              {                   
                  "Make": "Kia",
                  "ModelFamily": "Sorento",
                  "SubModel": null,
                  "Origin": "Korea",
                  "CcRating": "2200",
                  "Weight": "2500"                  
              },
              {                    
                  "Make": "Nissan",
                  "ModelFamily": "Pathfinder",
                  "SubModel": "SUV",
                  "Origin": "Japan",
                  "CcRating": "2000",
                  "Weight": "2000"                   
              }
          ]
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>This need to be done using windows powershell, Iam a java guy and have no idea how to do it using powershell except calling remote ftp server and read all xml files.
  Really appreciate, if someone could help me this. </p>