xml - 解析 XML 以导出到 CSV
问题描述
从 XML 格式的 IIS 配置文件中获取我想要的数据时遇到问题。本质上,我需要获取一堆受限 IP 地址以及 webappname 中的 4 个数字,即(示例/3780)名称并导出到 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>
现在我被困在基础上,只是想得到任何匹配的东西
$path = "\path\to\whatever.xml"
$xpath = "/configuration/location/system.webserver/security/ipsecurity"
select-xml -path $path -xpath $xpath |select-object ipaddress
解决方案
推荐阅读
- npm - Laravel 将 SCSS 混合到它自己的 CSS 文件中
- python - PyTorch 中 fc.bias 和 fc.weight 的大小不匹配
- r - 在 R 中按组创建新的 df 和记录百分比
- jquery - jQueryUI selectmenu - 如果另一个选择选择了某个选项,则禁用/启用选择
- javascript - 在 iFrame 中定义 customElements 会引发“DOMException:不支持操作”。为什么?
- javascript - 从同一类的异步方法调用类内的异步方法时的承诺(待定)
- javascript - webpack4 如何在生产模式下配置 postcss.config.js 文件
- asp.net-mvc - 将自定义标头值传递给 IdentityServer4 Login
- java - io.qameta.allure.testng.AllureTestNg 无法实例化
- c# - c# winforms 数组项被删除