我喜欢用powershell编辑节点并用随机数更新它
xml文件节点
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<Other appsCode="V7{}appsCont-12-Win-GM">
<Data key="appsnumbers">970767075516458272844213</Data>
</Other>
</Configuration>
脚本
# load XML file into local variable and cast as XML type.
$doc = [xml](Get-Content ./test.xml)
$doc.root.one
# find the value *970787075519458272844213* in the node and create a new one and update the xml files
$doc.save("./testNew.xml")
发布于 2019-03-04 09:32:18
IIRC $ doc.save()不接受相对路径。
根据mklement0的良好提示,我选择的补救措施是可以的,而原因并没有达到目的
## Q:\Test\2019\03\03\SO_54972848.ps1
$FileIn = ".\test.xml"
$FileOut= Join-Path (Get-Item .) "testNew.xml"
$doc = [xml](Get-Content $FileIn)
$doc.Configuration.Other.Data.'#text'
$doc.Configuration.Other.Data.'#text' = -join (1..24|%{get-random -min 0 -max 9})
$doc.Configuration.Other.Data.'#text'
$doc.save($FileOut)
https://stackoverflow.com/questions/-100006410
复制相似问题