How to merge elements from two XML files?

Posted by Googler on Stack Overflow See other posts from Stack Overflow or by Googler
Published on 2010-04-29T12:56:14Z Indexed on 2010/04/29 13:17 UTC
Read the original article Hit count: 289

Filed under:
|

Hi all,

I need a c# lang code to merge two xml files into one, from the specified content.

XML FILE 1 :

 <exchange-documents>
    <documentlegal>
      <bibliographic-data>        
          <applicants>
              <applicant-name>
                <name>CENTURY PRODUCTS CO [US]</name>
              </applicant-name>                         
          </applicants>       
       </bibliographic-data>
    </documentlegal>
  </exchange-documents>

XML FILE 2:

<exchange-documents>
    <documentpatent>
      <bibliographic-data>        
          <applicants>
              <applicant-name>
                <name>CENTURY PRODUCTS CO [US]</name>
              </applicant-name>                         
          </applicants>       
       </bibliographic-data>
    </documentpatent>
  </exchange-documents>

I need to read the above two xml files and write it into a new xml files with selected elements?

OUTPUT XML:

<documentlegal>
          <bibliographic-data>        
              <applicants>
                  <applicant-name>
                    <name>CENTURY PRODUCTS CO [US]</name>
                  </applicant-name>                         
              </applicants>       
           </bibliographic-data>
        </documentlegal>
  <documentpatent>
          <bibliographic-data>        
              <applicants>
                  <applicant-name>
                    <name>CENTURY PRODUCTS CO [US]</name>
                  </applicant-name>                         
              </applicants>       
           </bibliographic-data>
        </documentpatent>

I dont need the exchnage document element. Can anyone provide me a c# code to achiev the above scenario?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about c#