update node value of two similar type of XML files in C#

53 Views Asked by At

I am receiving two unknown format xml files from external source in my application. Normally both xml files are having identical structure but some time some nodes are different. I have to read one xml file node by node and update value in another xml file at similar position. Here I want to update File 2 value in File 1 and also want to find any extra node in File 2. How to achieve this?

File 1:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:Add xmlns:ns1='http://tempuri.org/'>
      <ns1:intA>?999?</ns1:intA>
      <ns1:intB>?999?</ns1:intB>
    </ns1:Add>
  </s11:Body>
</s11:Envelope>

File 2:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
  <s11:Body>
    <ns1:Add xmlns:ns1='http://tempuri.org/'>
      <ns1:intA>10</ns1:intA>
      <ns1:intB>20</ns1:intB>
      <ns1:intC>30</ns1:intC>
    </ns1:Add>
  </s11:Body>

Output:

<s11:Envelope xmlns:s11='http://schemas.xmlsoap.org/soap/envelope/'>
      <s11:Body>
        <ns1:Add xmlns:ns1='http://tempuri.org/'>
          <ns1:intA>10</ns1:intA>
          <ns1:intB>20</ns1:intB>
        </ns1:Add>
      </s11:Body>
    </s11:Envelope>
0

There are 0 best solutions below