H
Hvid Hat
How can I merge the following two XML documents:
Persons.xml
<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<name>Albert</name>
<department_id>1</department_id>
</person>
<person>
<name>Barry</name>
<department_id>2</department_id>
</person>
<person>
<name>Charlie</name>
<department_id>3</department_id>
</person>
</persons>
Departments.xml
<?xml version="1.0" encoding="UTF-8"?>
<departments>
<department>
<id>1</id>
<name>Management</name>
</department>
<department>
<id>2</id>
<name>Sales</name>
</department>
<department>
<id>3</id>
<name>Support</name>
</department>
</departments>
To generate the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<name>Albert</name>
<department>Management</department>
</person>
<person>
<name>Barry</name>
<department>Sales</department>
</person>
<person>
<name>Charlie</name>
<department>Support</department>
</person>
</persons>
Persons.xml
<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<name>Albert</name>
<department_id>1</department_id>
</person>
<person>
<name>Barry</name>
<department_id>2</department_id>
</person>
<person>
<name>Charlie</name>
<department_id>3</department_id>
</person>
</persons>
Departments.xml
<?xml version="1.0" encoding="UTF-8"?>
<departments>
<department>
<id>1</id>
<name>Management</name>
</department>
<department>
<id>2</id>
<name>Sales</name>
</department>
<department>
<id>3</id>
<name>Support</name>
</department>
</departments>
To generate the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<persons>
<person>
<name>Albert</name>
<department>Management</department>
</person>
<person>
<name>Barry</name>
<department>Sales</department>
</person>
<person>
<name>Charlie</name>
<department>Support</department>
</person>
</persons>