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>
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>
我试图将rules.xml(文件节点)的全部内容添加为profile.xml中的另一个节点.如您所见,profile.xml中有许多其他文件节点,rules.xml将是另一个.
这是我尝试过的代码,似乎没有做任何事情:
$xml = [xml](Get-Content ".\profile.xml") $newxml = [xml](Get-Content ".\rules.xml") $xml.ImportNode($newxml.get_DocumentElement(),$true) $xml.Save(".\profile.xml")
你真的很接近,但ImportNode只生成一个副本,实际上并没有将复制的节点插入到文档中.试试这个:
$newNode = $newxml.ImportNode($xml.get_DocumentElement(),$true) $newxml.DocumentElement.AppendChild($newNode) $xml.Save("$pwd\profile.xml")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。