解析XML以导出到CSV
以XML格式从IIS配置文件中获取所需数据时出现问题。实际上,我需要在webappname ie(示例/3780)名称中获取一组受限ip地址以及4个数字,然后导出到csv XML示例解析XML以导出到CSV,xml,powershell,Xml,Powershell,以XML格式从IIS配置文件中获取所需数据时出现问题。实际上,我需要在webappname ie(示例/3780)名称中获取一组受限ip地址以及4个数字,然后导出到csv XML示例 <location path="Example/3780_Proxy_Test_01418277"> <system.webServer> <security> <ipSecurity>
<location path="Example/3780_Proxy_Test_01418277">
<system.webServer>
<security>
<ipSecurity>
<add ipAddress="10.10.199.20" allowed="true" />
<add ipAddress="10.10.81.80" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="10.10.199.16" subnetMask="255.255.255.240" allowed="true" />
<add ipAddress="10.10.163.150" allowed="true" />
<add ipAddress="10.10.163.151" allowed="true" />
</ipSecurity>
</security>
</system.webServer>
</location>
<location path="Example/3200_Proxy">
<system.webServer>
<security>
<ipSecurity>
</ipSecurity>
</security>
</system.webServer>
</location>
xPath区分大小写
select xml-path$path-xpath'//ipsecurity'
不返回任何内容,但select xml-path$path-xpath'//ipsecurity'
返回预期的5个节点。xpath区分大小写select xml-path$path-xpath'//ipsecurity'
不返回任何内容,但select xml-path$path-xpath'//ipsecurity'
返回预期的5个节点。
$path = "\path\to\whatever.xml"
$xpath = "/configuration/location/system.webserver/security/ipsecurity"
select-xml -path $path -xpath $xpath |select-object ipaddress