Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Question regarding processing XML files

$
0
0

I want to compare 2 xml files and generate 3<sup>rd</sup> xml with below format.XML files size can be greater than 1GB.In this scenario what is the best approach to compare the two xml and generate the 3<sup>rd</sup> xml with <Action> element ? Also I want to reuse the same approach to compare xml with different structure.

I want to compare <Product> element  from ProductOriginal.xml with <Product> element from ProductUpdate.xml and generate 3rd xml with <Action> element which gives changes done to the original XML.

ProductOriginal.xml

<Data>

         <Header>

              <DateCreated>2014-10-31T03:16:20.002Z</DateCreated>

       </Header>

       <Body>

       <Products>

       <ProductCategory>Toys</ProductCategory>

              <Product>

          <ID>1</ID>

                     <Name>Toy1</Name>

                     <Color>Black</Color>

              </Product>

              <Product>

          <ID>2</ID>

                     <Name>Toy2</Name>

                     <Color>Green</Color>

              </Product>

       </Products>

       <Products>

       <ProductCategory>Cars</ProductCategory>

              <Product>

          <ID>3</ID>

                     <Name>Car1</Name>

                     <Color>Black</Color>

              </Product>

              <Product>

         <ID>4</ID>

                     <Name>Car2</Name>

                     <Color>Green</Color>

              </Product>

       </Products>

       </Body>

</Data>

ProductUpdate.xml

<Data>

         <Header>

              <DateCreated>2014-10-31T03:16:20.002Z</DateCreated>

       </Header>

       <Body>

       <Products>

       <ProductCategory>Toys</ProductCategory>

              <Product>

          <ID>1</ID>

                     <Name>Toy1</Name>

                     <Color>Red</Color>

              </Product>

              <Product>

          <ID>2</ID>

                     <Name>Toy2</Name>

                     <Color>Green</Color>

              </Product>

       </Products>

       <Products>

       <ProductCategory>Cars</ProductCategory>

              <Product>

         <ID>4</ID>

                     <Name>Car2</Name>

                     <Color>Green</Color>

              </Product>

    <Product>

      <ID>5</ID>

      <Name>Car3</Name>

      <Color>Black</Color>

    </Product>

       </Products>

       </Body>

</Data>

CompareResult.xml

<Data>

         <Header>

              <DateCreated>2014-10-31T03:16:20.002Z</DateCreated>

       </Header>

       <Body>

       <Products>

       <ProductCategory>Toys</ProductCategory>

              <Product>

         <ID>1</ID>

                     <Name>Toy1</Name>

                     <Color>Red</Color>

          <Action>Update</Action>

              </Product>

       </Products>

       <Products>

       <ProductCategory>Cars</ProductCategory>

   <Product>

     <ID>3</ID>

     <Name>Car1</Name>

     <Color>Black</Color>

     <Action>Delete</Action>

   </Product>

    <ProductAction="Insert">

      <ID>5</ID>

      <Name>Car3</Name>

      <Color>Black</Color>

      <Action>Insert</Action>

    </Product>

       </Products>

       </Body>

</Data>


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>