1

I have two large XML files with the same tree structure. File1.xml needs to be updated based on information to be found in File2.xml. All nodes that interest me are at the same level (2 from the root). An element of File1 looks like that

<item status="incorrect">
 <id> 1 </id>
 <data> incorrect_data </data>
 <other> something </other>
</item>

The corresponding element in File2 looks like

<item status="correct">
 <id> 1 </id>
 <data> correct_data </data>
 <other> something_else </other>
</item>

I would like to modify all elements in File1 (looking for elements in File2 having the same id) so as to obtain

<item status="correct">
 <id> 1 </id>
 <data> correct_data </data>
 <other> something </other>
</item>

That is, the attribute 'status' of 'item' should be changed and the text in the child 'data' also, as to match what is in File2. The rest (corresponding here to the child 'other') should be left unchanged.

I have seen a very similar question answered here. However, I am new to XML and any help for my particular problem would be much appreciated. I am happy to have an answer using XLST and the 'document' function. However, a solution using Matlab (with which I am more familiar) would also be very much appreciated.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.