need to merge 3 xml file datasets in C#

co0ll0v3

New Member
need to merge 3 xml file datasets that ALL have the different data, but all have a product_id and I want to merge those datasets and write out to a XML file with all the data from 3 files present.the 3 xml files are structured as below:parts.xml (as you can see there is nested product attributes, which vary on each product)\[code\]<?xml version="1.0"?> <ProductCatalog> <Products> <ProdID>7819</ProdID> <SKU>11078</SKU> <Description>SO-DIMM</Description> <Manufacturer>CORSAIR</Manufacturer> <ManufacturersPartNumber>VS1GSDS533D2</ManufacturersPartNumber> <ProductGroup>Memory</ProductGroup> <ProductImage>11078.jpg</ProductImage> <EAN>870584005179</EAN> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Package Contents</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Web Address</AttributeName> <AttributeValue>www.corsair.com</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Pins</AttributeName> <AttributeValue>200</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Type</AttributeName> <AttributeValue>SO-DIMM DDR2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>CAS Latency</AttributeName> <AttributeValue>4.0</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>No. of Chips</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Special Features</AttributeName> <AttributeValue>Lifetime Warranty</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Clock Speed</AttributeName> <AttributeValue>533MHz</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Product Name</AttributeName> <AttributeValue>Corsair 1GB (1x1GB) Value (SO-DIMM DDR2 533/4.0/1.8v) - VS1GSDS533D2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Package Type</AttributeName> <AttributeValue>Retail</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Compliance</AttributeName> <AttributeValue>PC2-4200</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Model Number</AttributeName> <AttributeValue>VS1GSDS533D2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Side</AttributeName> <AttributeValue>Double</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Chipset</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Warranty</AttributeName> <AttributeValue>10 Years</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Capacity</AttributeName> <AttributeValue>1GB</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Voltage</AttributeName> <AttributeValue>1.8v</AttributeValue> </Attributes> </Products>\[/code\]2nd file is pricing.xml\[code\]<?xml version="1.0"?><ProductCatalog> <Prices> <ProdID>22621</ProdID> <SKU>0234</SKU> <OnOffer>False</OnOffer> <PriceBreak1>1</PriceBreak1> <Discount1>5.48</Discount1> <OfferDiscount1>5.48</OfferDiscount1> <PriceBreak2>10</PriceBreak2> <Discount2>5.41</Discount2> <OfferDiscount2>5.41</OfferDiscount2> <PriceBreak3>20</PriceBreak3> <Discount3>5.35</Discount3> <OfferDiscount3>5.35</OfferDiscount3> <PriceBreak4>50</PriceBreak4> <Discount4>5.28</Discount4> <OfferDiscount4>5.28</OfferDiscount4> <PriceBreak5>100</PriceBreak5> <Discount5>5.22</Discount5> <OfferDiscount5>5.22</OfferDiscount5> </Prices>\[/code\]and the 3rd file is:\[code\]<?xml version="1.0"?><ProductCatalog> <Stock> <ProdID>22621</ProdID> <SKU>0234</SKU> <AvailQty>3</AvailQty> <OnOrder>10</OnOrder> <DueDate>02/04/2013</DueDate> <ProductStatus>36</ProductStatus> </Stock>\[/code\]as you can see all 3 files use the same "ProdID" and in summary I need the C# solution to read, merge and write the xml datasets into 1 master xml file. The structure needs to be as below:\[code\]<?xml version="1.0"?> <ProductCatalog> <Products> <ProdID>7819</ProdID> <SKU>11078</SKU> <Description>SO-DIMM</Description> <Manufacturer>CORSAIR</Manufacturer> <ManufacturersPartNumber>VS1GSDS533D2</ManufacturersPartNumber> <ProductGroup>Memory</ProductGroup> <ProductImage>11078.jpg</ProductImage> <EAN>870584005179</EAN> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Package Contents</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Web Address</AttributeName> <AttributeValue>www.corsair.com</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Pins</AttributeName> <AttributeValue>200</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Type</AttributeName> <AttributeValue>SO-DIMM DDR2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>CAS Latency</AttributeName> <AttributeValue>4.0</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>No. of Chips</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Special Features</AttributeName> <AttributeValue>Lifetime Warranty</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Clock Speed</AttributeName> <AttributeValue>533MHz</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Product Name</AttributeName> <AttributeValue>Corsair 1GB (1x1GB) Value (SO-DIMM DDR2 533/4.0/1.8v) - VS1GSDS533D2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Package Type</AttributeName> <AttributeValue>Retail</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Compliance</AttributeName> <AttributeValue>PC2-4200</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Model Number</AttributeName> <AttributeValue>VS1GSDS533D2</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Side</AttributeName> <AttributeValue>Double</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Chipset</AttributeName> <AttributeValue /> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Warranty</AttributeName> <AttributeValue>10 Years</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Capacity</AttributeName> <AttributeValue>1GB</AttributeValue> </Attributes> <Attributes> <ProdID>7819</ProdID> <SKU>11078</SKU> <AttributeName>Voltage</AttributeName> <AttributeValue>1.8v</AttributeValue> </Attributes> <AvailQty>3</AvailQty> <OnOrder>10</OnOrder> <DueDate>02/04/2013</DueDate> <ProductStatus>36</ProductStatus><OnOffer>False</OnOffer> <PriceBreak1>1</PriceBreak1> <Discount1>5.48</Discount1> <OfferDiscount1>5.48</OfferDiscount1> <PriceBreak2>10</PriceBreak2> <Discount2>5.41</Discount2> <OfferDiscount2>5.41</OfferDiscount2> <PriceBreak3>20</PriceBreak3> <Discount3>5.35</Discount3> <OfferDiscount3>5.35</OfferDiscount3> <PriceBreak4>50</PriceBreak4> <Discount4>5.28</Discount4> <OfferDiscount4>5.28</OfferDiscount4> <PriceBreak5>100</PriceBreak5> <Discount5>5.22</Discount5> <OfferDiscount5>5.22</OfferDiscount5> </Products>\[/code\]If I could merge the above data into a output like above that would be excellent.So far have managed to read the individual xml files into datasets, but the merging is not working for us based upon the prodID (effective primary key)this is just example data, but the structure/schema of the xml files are the same.
 
Back
Top