Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on 

Help with updating/adding data elements from fileB to fileA

Hello,

When I save my data I have file B, how do I look for same LinkAID in file A and replace its data elements with data elements in file B? and If LinkAID in file B is not in File A, How to I append its data elements in File A?


FileA:

<table>
<LinkAID>1<LinkAID>
<First>ItemA</First>
<Last>ItemB</Last>
<Date>Itemc</Date>
</table>
<table>
<LinkAID>2<LinkAID>
<First>ItemD</First>
<Last>ItemE</Last>
<Date>ItemF</Date>
</table>
<table>
<LinkAID>3<LinkAID>
<First>ItemG</First>
<Last>ItemH</Last>
<Date>ItemI</Date>
</table>


FileB:

<table>
<LinkAID>1<LinkAID>
<First>ItemA</First>
<Last>ItemB</Last>
<Date>temc</Date>
</table>
<table>
<LinkAID>2<LinkAID>
<First>ItemD</First>
<Last>ItemE</Last>
<Date>ItemF</Date>
</table>
<table>
<LinkAID>3<LinkAID>
<First>ItemG</First>
<Last>ItemH</Last>
<Date>temI</Date>
</table>
Visual Basic.NET.NET ProgrammingXML

Avatar of undefined
Last Comment
Victor Charles
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

How familiar are you with reading and writing XML documents?

You should just be able to query the one file for the LinkAID element and set its value based on the value you read from FileA - or append if not found.

Before writing any code - best to first understand the basics - so let us know what your level is and post any code you have attempted with this and lets take it from there.
Avatar of Victor  Charles

ASKER

Hi,

I know how to add data to an xml file but I need help with comparing values of an xml file with another xml file and then either add or replace values. Below is an example of saving data selected from a Grid to an xml file.

Dim MyDocLinkSSADB As XDocument = XDocument.Load(Application.StartupPath + "\LinkSSADB.xml")

            Dim LinkID = (From el In MyDocLinkSSADB.Descendants("LinkA") Select Int(el.<LinkAID>.Value)).ToList
            LinkID.Sort()
            Dim xNewLink As XElement = New XElement("LinkA")
            xNewLink.Add(New XElement("LinkAID", (LinkID.Last() + 1)))




            MyDocLinkSSADB.Root.Add(New XElement("LinkA", New XElement("LinkAID", (LinkID.Last() + 1)), New XElement("Order_ID", ComboBox1.SelectedIndex), New XElement("Problem_ID", SearchIdProblemeID), New XElement("POC_ID", POCid), New XElement("POC_ID", POC2id)))
            MyDocLinkSSADB.Save(Application.StartupPath + "\LinkSSADB.xml")

Thanks,


Victor
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Victor  Charles

ASKER

Hi,

Thanks for the link, but I still can't figure the code to solve this issue, can you please send me an example.

Thanks,

Victor
It will have to wait until next week - I am away until then - you can either request attention for a notification to be sent out to additional experts or hang on until next week.
Avatar of Victor  Charles

ASKER

OK, I will request attention for but would appreciate your help next week if this issue is not resolved. Thanks for your feedback.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo