Help with copying data of matching fields from file2 to file1 for matching Field value using VB.NET

Hi,

 If file1 contains the following data:

 <Root>
 <Table>
 <ID>1</ID>
 <NAD>MTHH</NAD>
<NAS>XXXX</NAS>
 </Table>
 <Table>
 <ID>2</ID>
 <NAD>UUTH</NAD>
 <NAS>YYYY</NAS>
 </Table>
 <Table>
 <ID>3</ID>
 <NAD></NAD>
 <NAS>ZZZZ</NAS>
 </Table>
 </Root>

 How do I create File3.xml with data from File 2 for all NAS values in file1 matching NAS values in File2 and only include fields in file2 matching with file 1?

 File 2:

 <Root>
 <Table>
 <ID>1</ID>
 <NAD>FFFFF</NAD>
 <NAS>XXXX</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 <Table>
 <ID>2</ID>
 <NAD>UUUU</NAD>
 <NAS>YYYY</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 <Table>
 <ID>3</ID>
 <NAD>DDDD</NAD>
 <NAS>ZZZZ</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 <Table>
 <ID>4</ID>
 <NAD>VVVVV</NAD>
 <NAS>ZZZZ</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 <Table>
 <ID>5</ID>
 <NAD>DVFVR</NAD>
 <NAS>OOOO</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 <Table>
 <ID>6</ID>
 <NAD>TTTTT</NAD>
 <NAS>NNNN</NAS>
 <ADG>VVVVV<AGD>
 <AKS>UUUUU<AKS>
 </Table>
 </Root>

 Based on NAS values in File1 the results in File3.xml should be as follows:

 <Root>
 <Table>
 <ID>1</ID>
<NAD>FFFFF</NAD>
 <NAS>XXXX</NAS>
 </Table>
 <Table>
  <ID>2</ID>
<NAD>UUUU</NAD>
 <NAS>YYYY</NAS>
 </Table>
 <Table>
 <ID>3</ID>
 <NAD>DDDD</NAD>
 <NAS>ZZZZ</NAS>
 </Table>
 </Root>


 Thanks,

 Victor
vcharlesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
do you want to know in how to proceed "logically", what components to use or plain code writing?

logically, I would load both file1 and file2 as XML documents
then, looping on the file1 <table> nodes, fetch the data from file2 based on a xquery to fetch the value for NAD, update it in the XML from file1 , and finally dump that one into file3

where exactly do you need help with?
0
vcharlesAuthor Commented:
Hi,

I need help with writing  the code, the files are in xml format..

Victor
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
as EE is not a rent-a-coder, please first try to get the sample code from the official documentations, like:
https://msdn.microsoft.com/en-us/library/system.xml.xmldocument%28v=vs.110%29.aspx

using the load method, to read from a file, you just use for example the TextReader techique:
https://msdn.microsoft.com/en-us/library/system.xml.xmldocument.load%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/system.io.textreader%28v=vs.110%29.aspx
0
it_saigeDeveloperCommented:
Not to mention, that you have asked this question before and have accepted solutions to it:

http:/Q_28664489.html
http:/Q_28647400.html

-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vcharlesAuthor Commented:
Yes, reverted back to old post and solved the issue.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.