XML tag replacement from different XML file

We have 2 XML file 1. ORIGINAL.xml file and 2. ATTRIBUTE.xml files, In the ORIGINAL.xml we need some modification as <resourceCode>431048</resourceCode>under <item type="Manufactured"> tag - we need to grab the 431048 value from tag and pass it to database table in unix shell script to find the model name and in our case the model number 22V50FM1, then we have to search in ATTRIBITE.xml file under <assignedAttributeList> tags, if found we have to copy the entire structure <assignedAttributeList> details and replace in ORIGINAL.xml file for the tag <assignedAttributeList></assignedAttributeList> under the resource code 431048.

Output shoudl be like MODIFIED. xml file

ORIGINAL.xml

<?xml version="1.0" encoding="UTF-8" ?>
<ps-persistence version="12.1.3">
<scenarioList>
<scenario>
<model>
<resourceCode>LIGHT</resourceCode>
<itemList>
<item type="Manufactured">
<resourceCode>431048</resourceCode>
<receivingCalendarCode>Default</receivingCalendarCode>
<assignedAttributeList></assignedAttributeList>
<timeVaryingEventList></timeVaryingEventList>
</item>
</itemList>
<itemList>
<item type="Manufactured">
<resourceCode>431049</resourceCode>
<receivingCalendarCode>Default</receivingCalendarCode>
<assignedAttributeList></assignedAttributeList>
<timeVaryingEventList></timeVaryingEventList>
</item>
</itemList>
</model>
</scenario>
</scenarioList>
</ps-persistence>

ATTRIBUTE.xml
-----------------------------------------------------------------------
<assignedAttributeList>
<assignedAttribute>
<attributeCode>Dia</attributeCode>
<attributeValueCode>18"</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Base</attributeCode>
<attributeValueCode>22V50FM1</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Fuel</attributeCode>
<attributeValueCode>Gas</attributeValueCode>
</assignedAttribute>
|</assignedAttributeList>
<assignedAttributeList>
<assignedAttribute>
<attributeCode>Dia</attributeCode>
<attributeValueCode>19"</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Base</attributeCode>
<attributeValueCode>22V50FM2</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Fuel</attributeCode>
<attributeValueCode>Electric</attributeValueCode>
</assignedAttribute>

</assignedAttributeList>

MODIFIED.xml
--------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<ps-persistence version="12.1.3">
<scenarioList>
<scenario>
<model>
<resourceCode>LIGHT</resourceCode>
<itemList>
<item type="Manufactured">
<resourceCode>431048</resourceCode>
<receivingCalendarCode>Default</receivingCalendarCode>
<assignedAttributeList>
<assignedAttribute>
<attributeCode>Dia</attributeCode>
<attributeValueCode>18"</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Base</attributeCode>
<attributeValueCode>22V50FM1</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Fuel</attributeCode>
<attributeValueCode>Gas</attributeValueCode>
</assignedAttribute>
| </assignedAttributeList>
<timeVaryingEventList></timeVaryingEventList>
</item>
</itemList>
<itemList>
<item type="Manufactured">
<resourceCode>431049</resourceCode>
<receivingCalendarCode>Default</receivingCalendarCode>
<assignedAttributeList>
<assignedAttribute>
<attributeCode>Dia</attributeCode>
<attributeValueCode>19"</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Base</attributeCode>
<attributeValueCode>22V50FM2</attributeValueCode>
</assignedAttribute>
<assignedAttribute>
<attributeCode>Fuel</attributeCode>
<attributeValueCode> Electric </attributeValueCode>
</assignedAttribute>
| </assignedAttributeList>
<timeVaryingEventList></timeVaryingEventList>
</item>
</itemList>
</model>
</scenario>
</scenarioList>
</ps-persistence>