打开/保存XML而节点的属性之间preserving换行符节点、属性、换行符、XML

由网友(優雅瘋℡姿態)分享简介:这是我到目前为止有:$XML = New-Object System.Xml.XmlDocument$XML.PreserveWhitespace = $true$XML.Load($path)#change some node attributes$XML.Save($path)如果我需要打开一个XML文件...

这是我到目前为止有:

$XML = New-Object System.Xml.XmlDocument
$XML.PreserveWhitespace = $true
$XML.Load($path)
#change some node attributes
$XML.Save($path)

如果我需要打开一个XML文件,并采取这样一个片段:

If I take open an XML file, and take a snippet like this:

<Node 
Name="tyjytj" 
Number="rthjr" 
Source="rjyrtjrjrtj" 
BinaryDrive="teheherhehtr" />

这将节省这样的:

It will save it like this:

<Node Name="tyjytj" Number="rthjr" Source="rjyrtjrjrtj" BinaryDrive="teheherhehtr" />

不过,我希望能够改变(例如)节点的名称,同时保持各属性之间的换行。我想要的格式,以保持完全究竟是怎么回事之前,我打开/保存它。

But I want to be able to change (for example) the Name of the Node, while keeping newlines between each attribute. I want the format to remain exactly how it was before I open/saved it.

推荐答案

在世界上没有任何XML解析器会告诉你是否在开始标记的属性由空格,换行,或制表符分隔。你不应该去关心。

No XML parser in the world is going to tell you whether the attributes in a start tag are separated by spaces, newlines, or tabs. You aren't supposed to care.

阅读全文

相关推荐

最新文章