我有这个XML,我需要将它解析为PowerShell中的一个表。我需要几行代码才能把它放到表格中
<RowTypes>
<RowType Id="70430" Label="JACS Principal Subject (2012/13 onwards)" />
<RowType Id="70431" Label="Cost Centre (2012/13 onwards)" />
<RowType Id="3297" Label="Institution" />
<RowType Id="3298" Label="HESACode Principal Subject" />
<RowType Id="3299" Label="Cost Centre (2003/04 & before)" />
<RowType Id="3300" Label="JACS Principal Subject (2006/07 & before)" />
<RowType Id="3301" Label="Cost Centre (2004/05 to 2011/12)" />
<RowType Id="3302" Label="JACS Principal Subject (2007/08 to 2011/12)" />
<RowType Id="3303" Label="Unit of assessment" />
<RowType Id="3304" Label="UCAS JACS Subject Line (2011/12 & before)" />
<RowType Id="68689" Label="UCAS JACS Subject Line (2012/13 onwards)" />
</RowTypes>
答案 0 :(得分:0)
读取文件的内容并将结果转换为xml:
PS>[xml]$x=gc c:\temp\xml.xml
PS>$x.rowtypes.rowtype | %{ echo "ID= $($_.Id) LABEL= $($_.Label))"}
ID= 70430 LABEL= JACS Principal Subject (2012/13 onwards))
ID= 70431 LABEL= Cost Centre (2012/13 onwards))
ID= 3297 LABEL= Institution)