我有以下XML:
<?xml version="1.0"?>
<Objects>
<Object Type="System.Management.Automation.PSCustomObject">
<Property Type="System.String" Name="FolderName">Mozilla_Firefox</Property>
<Property Type="System.Int32" Name="Export">6</Property>
</Object>
<Object Type="System.Management.Automation.PSCustomObject">
<Property Type="" Name="ExportListing"/>
<Property Type="System.String" Name="FolderName">Notepad</Property>
<Property Type="System.Int32" Name="ExportCountZips">1</Property>
</Object>
</Objects>
我想为特定的'FolderName'获取属性'Export'的值。 以下是我如何通过记事本获取XML Line:
$t = $xml.Objects.Object.Property |
? { $_.Name -eq 'FolderName'} |
Where '#text' -eq 'Notepad'
如何获得值为1的正确'ExportCountZips'?
答案 0 :(得分:1)
$ExportCountZips = ($xml.objects.object.property | Where-Object {$_.Name -eq "ExportCountZips"})."#text"
答案 1 :(得分:1)
data