Hi folks. I'm trying to grab xml elements within an xml file and save them to a csv file. The data is below. I tried to display (write-host) some of the data points thru this command below, but it does not seem to work.
[xml]$userfile = Get-Content "C:\Desktop\revenue.xml"
foreach ($user in $userfile.dashboardreport.data.chartdashlet.measures) {Write-Host $user.measurement}
What i'm trying to do is capture the data points within the "<measurement>" element below in the xml file. So basically grab the "timestamp", "avg", "min", "max", "sum", "count" numeric values and create column headers with those names (in a .csv file) and then place the numeric values under those column headers. Could someone please show me how i'd go by doing this? Thanks a bunch
<?xml version="1.0" encoding="utf-8"?>
<dashboardreport name="CEO report" version="6.1.1" reportdate="2016-01-05T10:41:43.442-05:00" description="">
<source name="Shop Revenue Sales" filtersummary="yesterday"></source>
<reportheader>
<reportdetails>
<user>d123456</user>
</reportdetails>
</reportheader>
<data>
<chartdashlet name="Chart" description="" showabsolutevalues="false">
<measures>
<measure measure="Store revenue" color="#4a590d" aggregation="Average" avg="615.6785497960142" unit="ms" min="181.9940808496952" max="899.4345004147291" sum="59105.14078041736" count="11696111">
<measurement timestamp="1451883600000" avg="402.1340608888865" min="7.7162299156188965" max="26187.892578125" sum="3519075.166838646" count="8751"></measurement>
<measurement timestamp="1451884500000" avg="389.9725918607622" min="7.4086480140686035" max="28727.447265625" sum="3014878.1076755524" count="7731"></measurement>
<measurement timestamp="1451885400000" avg="404.0337494542526" min="7.6969380378723145" max="71719.296875" sum="3180149.641954422" count="7871"></measurement>
<measurement timestamp="1451886300000" avg="358.9768303754391" min="7.6201348304748535" max="20709.013671875" sum="2747249.6828632355" count="7653"></measurement>
<measurement timestamp="1451887200000" avg="327.90299308649253" min="6.456700801849365" max="26625.943359375" sum="2328111.250914097" count="7100"></measurement>
<measurement timestamp="1451888100000" avg="325.6388628116827" min="6.60880708694458" max="40149.37109375" sum="2000399.5342521667" count="6143"></measurement>
<measurement timestamp="1451889000000" avg="297.1601526103318" min="7.929952144622803" max="40137.4375" sum="1876566.3637342453" count="6315"></measurement>
<measurement timestamp="1451889900000" avg="274.07286379153913" min="8.092523574829102" max="24451.16015625" sum="1567696.7808876038" count="5720"></measurement>
</measure>
</measures>
</chartdashlet>
</data>
</dashboardreport>