我是Powershell的新手,我不想获取这个xml的所有id(xml不能更改
因为这只是我问题的一个假象)
<?xml version="1.0" encoding="ISO-8859-1"?>
<List>
<Person1>
<Id>E00023</Id>
<empName>Aadharsh</empName>
</Person1>
<Person2>
<Id>E00042</Id>
<empName>Raksha</empName>
</Person2>
</List>
通过这段代码,我只得到Person1的Id:
$XMLfile = 'C:\test.xml'
[XML]$empDetails = Get-Content $XMLfile
foreach($module in $empDetails.List.Person1){
Write-Host "Id :" $module.Id
}
我尝试了以下代码,但不起作用:(
问题是Person1和Person2是不同的名字。
我需要更改什么才能获得所有身份证?
$XMLfile = 'C:\test.xml'
[XML]$empDetails = Get-Content $XMLfile
foreach($module in $empDetails.List.$module){
Write-Host "Id :" $module.Id
}