需要<ColourAddon>red</ColourAddon>在以下 xml 中的 GSIset 中添加此元素:
<?xml version="1.0" standalone="yes"?>
<GSIExplorer>
<GSISet>
<ID>local</ID>
<GSIServer>localhost</GSIServer>
<ALERT_TIMEOUT>30</ALERT_TIMEOUT>
</GSISet>
</GSIExplorer>
Run Code Online (Sandbox Code Playgroud)
我使用的代码是这样的:
[xml]$Xmlnew = Get-Content "C:\Program Files (x86)\GSI\gsiSettings\gsiPSSSettings2.xml"
$test = $Xmlnew.CreateElement("ColourAddon","red")
$Xmlnew.GSIExplorer.GSISet.AppendChild($test)
$Xmlnew.save("C:\Program Files (x86)\GSI\gsiSettings\gsiPSSSettings3.xml")
Run Code Online (Sandbox Code Playgroud)
我得到的结果是这样的
<?xml version="1.0" standalone="yes"?>
<GSIExplorer>
<GSISet>
<ID>local</ID>
<GSIServer>localhost</GSIServer>
<ALERT_TIMEOUT>30</ALERT_TIMEOUT>
<Colouraddon xmlns="asda" />
</GSISet>
</GSIExplorer>
Run Code Online (Sandbox Code Playgroud)
我想要这个:
<?xml version="1.0" standalone="yes"?>
<GSIExplorer>
<GSISet>
<ID>local</ID>
<GSIServer>localhost</GSIServer>
<ALERT_TIMEOUT>30</ALERT_TIMEOUT>
<ColourAddon>red</ColourAddon>
</GSISet>
</GSIExplorer>
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?