Victor Charles
asked on
Help with tranfereing data to anoth xml file
Hello,
I used the code below to save ID values of an xml file based using “Where (c.Element("LinkAID").Valu e = Link_ID). I now modifed the code to save IDs for all records in using “Where (c.Element("LinkAID").Valu e <> 0)” How do I add a loop to transfer all the records instaed of one record where ("LinkAID").Value = Link_ID?.
Dim MyLink As XDocument = XDocument.Load(Application .StartupPa th + "\App_DataA\LinkSSADB.xml" )
Dim XT As XElement = XElement.Load(Application. StartupPat h + "\App_Data\LinkSSADB.xml")
Dim GetNodeForID = From c In XT.Elements("LinkA")
Where (c.Element("LinkAID").Valu e <> “”)
Select New XElement("LinkA",
New XElement("LinkAID", c.Element("LinkAID").Value ),
New XElement("CountryUser_ID", c.Element("CountryUser_ID" ).Value),
New XElement("CountryOrigin_ID ", c.Element("CountryUser_ID" ).Value),
New XElement("NSN_ID", c.Element("NSN_ID").Value) ,
New XElement("FTL_ID", c.Element("FTL_ID").Value) )
If (Not IsNothing(GetNodeForID)) And (GetNodeForID.Any()) Then
MyLink.Element("Root").Add (GetNodeFo rID.First)
MyLink.Save((Application.S tartupPath + "\App_DataA\LinkSSADB.xml" ))
End If
I used the code below to save ID values of an xml file based using “Where (c.Element("LinkAID").Valu
Dim MyLink As XDocument = XDocument.Load(Application
Dim XT As XElement = XElement.Load(Application.
Dim GetNodeForID = From c In XT.Elements("LinkA")
Where (c.Element("LinkAID").Valu
Select New XElement("LinkA",
New XElement("LinkAID", c.Element("LinkAID").Value
New XElement("CountryUser_ID",
New XElement("CountryOrigin_ID
New XElement("NSN_ID", c.Element("NSN_ID").Value)
New XElement("FTL_ID", c.Element("FTL_ID").Value)
If (Not IsNothing(GetNodeForID)) And (GetNodeForID.Any()) Then
MyLink.Element("Root").Add
MyLink.Save((Application.S
End If
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi,
It worked. One more small issue. How do I clear the xml file before I insert new data in it?
Thanks,
Victor
It worked. One more small issue. How do I clear the xml file before I insert new data in it?
Thanks,
Victor
ASKER
Thank You!
ASKER