我有一个非常简单的 xml,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<First>
<Second>
<Folder>today</Folder>
<FileCount>10</FileCount>
</Second>
<Second>
<Folder>tomorrow</Folder>
<FileCount>90</FileCount>
</Second>
<Second>
<Folder>yesterday</Folder>
<FileCount>22</FileCount>
</Second>
</First>
然后我有一个 powershell 脚本来选择“文件夹”元素:
[xml]$xml=Get-Content "D:\m.xml"
$xml.SelectNodes("//Folder")
它输出:
#text
-----
today
tomorrow
yesterday
没问题。但是,如果我更改 xml 文件以将“xmlns="http://schemas.microsoft.com/developer/msbuild/2003" 添加到“First”,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<First xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Second>
<Folder>today</Folder>
<FileCount>10</FileCount>
</Second>
<Second>
<Folder>tomorrow</Folder>
<FileCount>90</FileCount>
</Second>
<Second>
<Folder>yesterday</Folder>
<FileCount>22</FileCount>
</Second>
</First>
然后,我的 powershell 脚本什么也不输出。为什么?如何更改我的 powershell 脚本以支持此 xmlns?
非常感谢。