Powershell: convert XmlDocument to XmlNode -


i wondering if possible convert xml document xml node in powershell. afterwards, each property or attach node onto xml file.

i found 'import-clixml' error think know how fix, want know if can bypass that.

import-clixml : element 'objs' namespace name 'http://schemas.microsoft.com/powershell/2004/04' not found. line 2, position 2. @ line:1 char:1 + import-clixml .\flschobvwcgrb1.xml + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : notspecified: (:) [import-clixml], xmlexception     + fullyqualifiederrorid : system.xml.xmlexception,microsoft.powershell.commands.importclixmlcommand 

edit:

without converting xmldocument , appending onto xmldocument

this powershell script used:

$xml = new-object xml $xml.load('c:\users\acer\desktop\big.xml') $servers = select-xml -xml $xml -xpath '//servers' $doc = [xml](gc 'c:\users\acer\desktop\node.xml') $servers.node.appendchild($doc) 

this error:

exception calling "appendchild" "1" argument(s): "the specified node cannot inserted valid child of node, because specified node wrong type." @ line:6 char:1 + $servers.node.appendchild($doc) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + categoryinfo          : notspecified: (:) [], methodinvocationexception     + fullyqualifiederrorid : dotnetmethodexception 

if want add node 1 document another, have import first:

$xml = new-object xml $xml.load('c:\users\acer\desktop\big.xml') $servers = select-xml -xml $xml -xpath '//servers' $doc = [xml](gc 'c:\users\acer\desktop\node.xml') $imported=$xml.importnode($doc.documentelement,$true) $servers.node.appendchild($imported) $xml.save('c:\users\acer\desktop\big2.xml') 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -