Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析XML以导出到CSV_Xml_Powershell - Fatal编程技术网

解析XML以导出到CSV

解析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>

以XML格式从IIS配置文件中获取所需数据时出现问题。实际上,我需要在webappname ie(示例/3780)名称中获取一组受限ip地址以及4个数字,然后导出到csv

XML示例

 <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