<tickets type="array">
<ticket>
<assigned-user-id type="integer">123</assigned-user-id>
<closed type="boolean">true</closed>
<creator-id type="integer">177522</creator-id>
<number type="integer">306</number>
<state>resolved</state>
<tag nil="true"/>
<title>
title text 1
</title>
<updated-at type="datetime">2012-03-14T13:13:11+11:00</updated-at>
<user-id type="integer">96438</user-id>
<version type="integer">3</version>
<user-name>Username</user-name>
</ticket>
</tickets>
我是Powershell的新手,在xml和format-table方面遇到了一个问题。给定上面的xml文件。如果我运行下面的脚本来显示表格中的票务,"number"和"closed"的值无法显示。
$t = [xml](new-object system.net.webclient).downloadstring($xmlfilepath)
$t.tickets.ticket | Format-Table -Property title, state, user-name, url, number, closed
返回:
title state user-name number closed
----- ----- --------- ------ ------
title text 1 resolved Username number closed
title text 2 resolved Username number closed
这是唯一的方法吗?我必须使用foreach
和selectSingleNode("ticket").get_InnerXml()
来获取所有的值吗?
谢谢。