簡體   English   中英

從一個xml文件復制到另一個-Powershell

[英]Copy from one xml file to another - powershell

Zdravo! 現在,這個問題困擾着我很多……我正嘗試使用powershell將幾個節點從一個XML文件復制到另一個文件,並環顧整個互聯網,但是似乎只有在我的個人電腦上才是通用解決方案問題不起作用。 這是我現在得到的代碼:

#loading one document
$xml = New-Object XML
$xml.Load("C:\Inetpub\WWWroot\web.config")

#load another
$wconfig = New-Object XML
$wconfig.Load("C:\Users\foo\test.enc")

#now do what everyone on the internet says
$xml.DocumentElement.InsertAfter($wconfig.ImportNode($wconfig.SelectSingleNode($node), $true), $afterNode))

任何人都知道為什么這個(以及其他幾個替代方案,如.Clone())總是返回“要插入的節點來自不同的文檔上下文”。 或者只是給我另一種選擇。 任何有效的方法:D

謝謝

我認為應該是$XML.ImportNode($wconfig.SelectSingleNode ...等等而不是$wconfig.ImportNode($wconfig.SelectSingleNode

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM