0
我正在使用C#。Xml元素覆蓋
我有2個xml文件,這就是看相同execpt特定的元素值:
原始文件:
<tasks>
<task id="1" >
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<CipherData>
<CipherValue>+bv8xdFfDzXai3rB1D+c2voJ/mRkuQHJfV34iWB2wyezR3wxG5UnLmznq4i2emIh4Z+8KukZEKJmM8=</CipherValue>
</CipherData>
</EncryptedData>
<AnotherElements/>
</task>
<task id="2" >
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<CipherData>
<CipherValue>+bv8xdFfDzXai3rB1D+c2voJ/mRkuQHJfV34iWB2wyezR3wxG5UnLmznq4i2emIh4Z+8KukZEKJmM8=</CipherValue>
</CipherData>
</EncryptedData>
<AnotherElements/>
</task>
...
<tasks>
而且備份文件:
<tasks>
<task id="1" >
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<CipherData>
<CipherValue>+asd+c2voJ/sdf+8KukZEKJmM8=</CipherValue>
</CipherData>
</EncryptedData>
<AnotherElements/>
</task>
<task id="2" >
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<CipherData>
<CipherValue>+asd+c2voJ/sdf+8KukZEKJmM8=</CipherValue>
</CipherData>
</EncryptedData>
<AnotherElements/>
</task>
...
<tasks>
在原有的錯誤的情況下文件,因爲<EncryptedData>
元素我想從原始文件中的備份文件中替換所有<EncryptedData>
元素。
這樣做的最好方法是什麼?