0
我想使用PowerShell來加載一個XML並顯示沒有設置父節點的所有節點的名稱。這可能嗎?通過PowerShell獲取所有的孩子在沒有命名標記的情況下通過powershell
這裏是我到目前爲止的代碼:
[xml]$changesXML = Get-Content $PathToXML
function ReplaceOneFormat
{
Param(
$Parent
)
foreach($child in $Parent)
{
$child.Name?
#ReplaceOneFormat $child # call this function by recursive
}
}
ReplaceOneFormat $changesXML
所以,這是我的示例XML:
<?xml version="1.0"?>
<books>
<book author="a">1</book>
<book author="b">2</book>
<book author="c">
<page>796</page>
<language>USA</language>
<Publisher>USAFM</Publisher>
</book>
<journal>L2</journal>
<journal>
<book author="d">L3</book>
<Publisher>USAFM</Publisher>
</journal>
</books>
我需要得到這樣的:
Node: Value:
books
book 1
book 2
book
page 796
language USA
Publisher USAFM
journal L2
journal
book L3
Publisher USAFM
請提供樣本輸入和期望輸出。 – vonPryz 2014-11-06 16:48:40
有趣的問題。我有同樣的任務,但我做不到,你需要什麼。 – user3231442 2014-11-07 08:19:56