I have the following XML received from a web service in a PowerShell variable $res
<GRID>
<DATA>
<R>
<D>2645</D>
<D>[email protected]</D>
<D>2019-09-27 10:17:36.0</D>
<D>114041</D>
<D>Awaiting Planning</D>
<D>Work Planned</D>
</R>
<R>
<D>2649</D>
<D>[email protected]</D>
<D>2019-09-27 10:33:24.0</D>
<D>114043</D>
<D>Awaiting Release</D>
<D>Awaiting Planning</D>
</R>
<R>
<D>2652</D>
<D>[email protected]</D>
<D>2019-09-27 10:36:53.0</D>
<D>114041</D>
<D>Awaiting Planning</D>
<D>Work Planned</D>
</R>
</DATA>
</GRID>
I want to export the R nodes as rows and D node values as columns into a CSV file in PowerShell. I did the following:
$res.GRID.DATA.R | Export-Csv .\GRID1.csv
The result is the correct number of rows, but columns do not appear, instead I get the object type like so:
"D"
"System.Object[]"
"System.Object[]"
"System.Object[]"
What is the quickest way to get the columns converted to comma separated values ?
Many Thanks