如何使用powershell在特定标记中搜索属性



我需要在xml中搜索属性。在标记内指定。

示例:我需要搜索结果属性

<root>
<college>
<student>
<course>
<table></table>
</course>
<student>
<staff>
<table name="result"></table>
</staff>
</college>
<school>
<table name="list"></table>
</school>
</root>

result属性可以是我需要搜索该属性的任何位置。它不是专门针对一个xml文件的。它需要适用于任何xml。如果结果属性可用。它需要被识别。

如何实现

提前感谢

您可以通过简单地命名属性来用XPath表示属性的存在:

$xml.SelectNodes('//*[@result]')

最新更新