gpt4 book ai didi

xml - 如何在 powershell 中打印 xml 元素的实际内容?

转载 作者:数据小太阳 更新时间:2023-10-29 02:03:32 26 4
gpt4 key购买 nike

当尝试使用 powershell 解析 xml 文件中的各种数据时,能够查看各种元素的实际含义对于调试等非常有用。所以如果我有这样的事情:

[xml]$xmldoc = Get-Content doc.xml
$node = $xmldoc.SelectSingleNode("contents/some/path/items/item[name='itemname']")
$items = $xmldoc.contents.some.path.items

write-host "items = [${items}], node = [${node}]"

我希望能够看到 $items 和 $node 的内容,但我得到的只是 System.Xml.XmlDocument 或 System.Xml.XmlElement。当我尝试使用 items.Value 或 items.InnerText 时,它们显示为空,那么如何打印这些元素的实际文本?

最佳答案

查看 the XmlElement class .具体来说,属性。我怀疑您在寻找 .InnerXml.OuterXml

关于xml - 如何在 powershell 中打印 xml 元素的实际内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45489155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com