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

How to combine 2 XMl nodes from the same document when they have child node with same value

$
0
0


-<NewDataSet>


-<Header>

<BankName>SAMA</BankName>

<CashCenterName>SAMA Riyadh</CashCenterName>

</Header>


-<DepositorList>

<ReferenceNumber>1</ReferenceNumber>

<DepositList_Id>0</DepositList_Id>

<PreparedBy>FZE</PreparedBy>

<TotalContainerCount>2</TotalContainerCount>

<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>

<DeclaredAmount>150000</DeclaredAmount>

</DepositorList>


-<DepositorList>

<ReferenceNumber>1</ReferenceNumber>

<DepositList_Id>1</DepositList_Id>

<PreparedBy>FZE</PreparedBy>

<TotalContainerCount>2</TotalContainerCount>

<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>

<DeclaredAmount>500000</DeclaredAmount>

</DepositorList>


-<DepositorList>

<ReferenceNumber>1</ReferenceNumber>

<DepositList_Id>2</DepositList_Id>

<PreparedBy>FZE</PreparedBy>

<TotalContainerCount>2</TotalContainerCount>

<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>

<DeclaredAmount>2100000</DeclaredAmount>

</DepositorList>


-<DepositorList>

<ReferenceNumber>1</ReferenceNumber>

<DepositList_Id>3</DepositList_Id>

<PreparedBy>FZE</PreparedBy>

<TotalContainerCount>2</TotalContainerCount>

<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>

<DeclaredAmount>1100000</DeclaredAmount>

</DepositorList>


-<DepositorList>

<ReferenceNumber>1</ReferenceNumber>

<DepositList_Id>4</DepositList_Id>

<PreparedBy>FZE</PreparedBy>

<TotalContainerCount>2</TotalContainerCount>

<ExpectedDate>2018-04-19T09:13:10-05:00</ExpectedDate>

<DeclaredAmount>1200000</DeclaredAmount>

</DepositorList>


-<Carrier>

<CarrierName>tns1:Commercial CIT</CarrierName>

<CarrierNumber>10001</CarrierNumber>

<CarrierLocationName>tns1:Riyadh</CarrierLocationName>

<CarrierLocationNumber>100011</CarrierLocationNumber>

<CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName>

<CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber>

<DepositList_Id>0</DepositList_Id>

</Carrier>


-<Carrier>

<CarrierName>tns1:Commercial CIT</CarrierName>

<CarrierNumber>10001</CarrierNumber>

<CarrierLocationName>tns1:Riyadh</CarrierLocationName>

<CarrierLocationNumber>100011</CarrierLocationNumber>

<CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName>

<CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber>

<DepositList_Id>1</DepositList_Id>

</Carrier>


-<Carrier>

<CarrierName>tns1:Commercial CIT</CarrierName>

<CarrierNumber>10001</CarrierNumber>

<CarrierLocationName>tns1:Riyadh</CarrierLocationName>

<CarrierLocationNumber>100011</CarrierLocationNumber>

<CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName>

<CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber>

<DepositList_Id>2</DepositList_Id>

</Carrier>


-<Carrier>

<CarrierName>tns1:Commercial CIT</CarrierName>

<CarrierNumber>10001</CarrierNumber>

<CarrierLocationName>tns1:Riyadh</CarrierLocationName>

<CarrierLocationNumber>100011</CarrierLocationNumber>

<CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName>

<CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber>

<DepositList_Id>3</DepositList_Id>

</Carrier>


-<Carrier>

<CarrierName>tns1:Commercial CIT</CarrierName>

<CarrierNumber>10001</CarrierNumber>

<CarrierLocationName>tns1:Riyadh</CarrierLocationName>

<CarrierLocationNumber>100011</CarrierLocationNumber>

<CarrierLocationRouteName>tns1:R1</CarrierLocationRouteName>

<CarrierLocationRouteNumber>R1</CarrierLocationRouteNumber>

<DepositList_Id>4</DepositList_Id>

</Carrier>

</NewDataSet>

Here I want to combine DepositorList node with Carrier Node as you can see they have DepositList_Id as a common child

The output I am expecting is


-<tns:Header>


<tns1:BankName>SAMA</tns1:BankName>

<tns1:CashCenterName>SAMA Riyadh</tns1:CashCenterName>

</tns:Header>


-<tns:DepositList>

<tns1:ReferenceNumber>00000001</tns1:ReferenceNumber>


-<tns1:Carrier>

<tns1:CarrierName>tns1:Commercial CIT</tns1:CarrierName>

<tns1:CarrierNumber>10001</tns1:CarrierNumber>

<tns1:CarrierLocationName>tns1:Riyadh</tns1:CarrierLocationName>

<tns1:CarrierLocationNumber>100011</tns1:CarrierLocationNumber>

<tns1:CarrierLocationRouteName>tns1:R1</tns1:CarrierLocationRouteName>

<tns1:CarrierLocationRouteNumber>R1</tns1:CarrierLocationRouteNumber>

</tns1:Carrier>

<tns1:PreparedBy>FZE</tns1:PreparedBy>

<tns1:TotalContainerCount>2</tns1:TotalContainerCount>

<tns1:ExpectedDate>2018-04-19T09:13:10-05:00</tns1:ExpectedDate>

<tns1:DeclaredAmount>150000.00</tns1:DeclaredAmount>

</tns:DepositList>

......Likewise for others

I have not worked much with XMl in C#, getting confused a lot tried merge but it just merges it down to the existing node and changes the node name as well .. Please suggest


Viewing all articles
Browse latest Browse all 935

Trending Articles



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