Content of profile.xml:
<files>
<file folder="CaptureServer" filename="CSConfig" object="CSConfig">
<Profile name="BBH1200Kofax">
<OutputCache>\</OutputCache>
<EncryptedConnectionString>564rgr=</EncryptedConnectionString>
<ConvertDocsBeforeRelease>false</ConvertDocsBeforeRelease>
</Profile>
</file>
<file folder="CaptureServices3" filename="CSConfig" object="CSConfig">
<Profile name="BBH1200Kofax">
<ReleaseToEnterprise>true</ReleaseToEnterprise>
<CaptureServerUrl />
<OutputCache />
<Credentials>
<EncryptedPassword>46s4rg=</EncryptedPassword>
<UserName />
<Domain />
</Credentials>
<ConvertDocsBeforeRelease>false</ConvertDocsBeforeRelease>
</Profile>
</file>
</files>
Content of rules.xml:
<file folder="" filename="Rules" object="ArrayOfIBarcodeRule">
<Profile name="Test471">
<IBarcodeRule>
<RuleName>DOC-TESTTESTTEST-Code128</RuleName>
<FieldSequenceNumber>1</FieldSequenceNumber>
<FieldRectangle>
<Location>
<X>0</X>
<Y>0</Y>
</Location>
<Size>
<Width>0</Width>
<Height>0</Height>
</Size>
</FieldRectangle>
<SeparationValue>TESTTESTTEST</SeparationValue>
</IBarcodeRule>
</Profile>
</file>
I am trying to add the entire contents of rules.xml (the file node) as another node in profile.xml. As you can see, there are a bunch of other file nodes in the profile.xml, and the rules.xml would be another one.
This is the code I have tried, and it does not seem to do anything:
$xml = [xml](Get-Content ".\profile.xml")
$newxml = [xml](Get-Content ".\rules.xml")
$xml.ImportNode($newxml.get_DocumentElement(), $true)
$xml.Save(".\profile.xml")
You're really close but ImportNode only makes a copy and doesn't actually insert the copied nodes into the document. Try this:
$newNode = $newxml.ImportNode($xml.get_DocumentElement(), $true)
$newxml.DocumentElement.AppendChild($newNode)
$xml.Save("$pwd\profile.xml")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With