I have the following two XML files:
File1
<?xml version="1.0"?>
<main>
<node1>
<subnode1>
<value1>101</value1>
<value2>102</value2>
<value3>103</value3>
</subnode1>
<subnode2>
<value1>501</value1>
<value2>502</value2>
<value3>503</value3>
</subnode2>
</node1>
</main>
File2
<?xml version="1.0"?>
<main>
<node1>
<subnode1>
<value1>454</value1>
<value2>471</value2>
<value3>498</value3>
</subnode1>
<subnode2>
<value1>723</value1>
<value2>645</value2>
<value3>823</value3>
</subnode2>
</node1>
</main>
In Delphi I would like to add the complete <node1>...</node1> structure of File2 to File1 renamed as <node2>...</node2>. So the result should look like this:
<?xml version="1.0"?>
<main>
<node1>
<subnode1>
<value1>101</value1>
<value2>102</value2>
<value3>103</value3>
</subnode1>
<subnode2>
<value1>501</value1>
<value2>502</value2>
<value3>503</value3>
</subnode2>
</node1>
<node2>
<subnode1>
<value1>454</value1>
<value2>471</value2>
<value3>498</value3>
</subnode1>
<subnode2>
<value1>723</value1>
<value2>645</value2>
<value3>823</value3>
</subnode2>
</node2>
</main>
I asked already how to extract the <node1>...</node1> block in the question
How to extract the inner text and XML of node as string?
(which was indeed a XY-problem, sorry about that) and I could work out a solution with manipulating the XML as strings.
But I suppose there might be a better solution working directly with the XML functionality. So how could I implement this in Delphi 10?