powershell XML操作
生活随笔
收集整理的這篇文章主要介紹了
powershell XML操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.直接加入xml結構
加入<title>是為了后續能直接添加其他node,否則,后續操作可能無法AppendChild
$xml = "<?xml version='1.0' encoding='UTF-8'?><case><title>please check each point</title></case>"$xml|Out-File $xmlFile2.讀取xml文件
加入 -Encoding UTF8 中文不亂碼
$xmldata =[XML](Get-Content $xmlFile -Encoding UTF8) $pointCount=$xmldata.case.SelectNodes("point").Count+13.字標簽添加
$innerXml = " <number>$pointCount</number> <name>$nameValue</name> <result>$resultValue</result> <filePath>$filePathValue</filePath> <time>$timeValue</time> <mark>$markValue</mark> "$newPoint = $xmldata.CreateElement("point") $newPoint.set_InnerXML($innerXml) $xmldata.case.AppendChild($newPoint)?
4.保存
$xmldata.Save($xmlFile)?
總結
以上是生活随笔為你收集整理的powershell XML操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 快捷键/hotkey简单例子
- 下一篇: powershell XML数据保存为H