0
我有具有以下結構的xml文件。如何驗證節點值並根據條件記錄該值?
<NodeData>
<XPath>//VersionInfo/VersionList[Name = "FileCopy"]</XPath>
<Node>
<VersionList xmlns="">
<Name>Core_FileCopy</Name>
<Version>10.21.1.3</Version>
</VersionList>
</Node>
</NodeData>
我正在取值版本和名稱,並將它們存儲在日誌文件中。
$FileList= Get-Childitem -path "Z:\XmlFiles" -Include "*.xml" -recurse | ?{$_.GetType() -ne [System.IO.DirectoryInfo]}
$LikeArray = @("10.21.*","10.20.*","10.11.*")
Foreach ($File in $Filelist) {
"Processing file $File.FullName"
$xmldata= [xml] (Get-content $File.FullName);
$VersionLists = $xmldata.SelectNodes("//VersionList") # Get the versionlist node
# If it has VersionList node
If ($VersionLists -ne $null) {
Foreach ($VersionList in $VersionLists) {
$VersionList | Select Version | Where-Object {$_ -notlike $LikeArray }
}
}
}
但我需要同時存儲的名稱和版本僅當它不具有的版本號
( 「10.21。」, 「10.20。」,「10.11。*)。
我已經修改了我的病情,但仍然會顯示所有的版本號