Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with merging multiple files in file1 based on identical values in file2 using VB.NET

Hi,

If file1.xml contains:

<?xml version="1.0" encoding="utf-8"?>
<Root>
  <AOP6A>
    <SN>10412</SN>
    <CHPT>104</CHPT>
    <CA></CA>
</AOP6A>
  <AOP6A>
    <SN>10471</SN>
    <CHPT>105</CHPT>
    <CA></CA>
  </AOP6A>
</Root>

and file2.xml contains:

<?xml version="1.0" encoding="utf-8"?>
<Root>
  <AOP5>
    <SN>10412</SN>
    <CHPT>104</CHPT>
    <Ctry>BEL</Ctry>
</AOP5>
  <AOP5>
    <SN>10412</SN>
    <CHPT>105</CHPT>
    <Ctry>FRA</Ctry>
  </AOP6A>

How do I enter Ctry values to iCA element in file1 based on matching SN, for example above, file1.xml should be as follows:

<?xml version="1.0" encoding="utf-8"?>
<Root>
  <AOP6A>
    <SN>10412</SN>
    <CHPT>104</CHPT>
    <CA>BEL,FRA</CA> 'Data from file2 based on SN = 10412 in both files
</AOP6A>
  <AOP6A>
    <SN>10471</SN>
    <CHPT>105</CHPT>
    <CA></CA>
  </AOP6A>
</Root>
 
Thanks,

Victor
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Victor  Charles

ASKER

Thanks, will try it and get back to you.
Hi Fernando,

How do you modify the code to remove duplicates in <CA> and also sort the data.

Thank You.

victor
Hi,

I am able to sort the data In CA, but how do you remove or avoid duplicates in <CA>.

Thanks,

Victor
Hi,

The solution for the second question in in another post.

Thanks,

victor
Thank You!
Not a problem Victor, glad to help.