Victor Charles
asked on
Help with saving duplicate data found to an xml file
Hi,
The code below checks successfully for duplicates but I need to use the existing ID of the matching record insated of creating a new record. I included a messagebox to tell the user the data entered already exist, but instead of the messagebox, I would prefer to save the existing ID (ReceiverID) of the matching record to another xml file.
'Receiver()
Dim MyDocReceiver As XDocument = XDocument.Load(Application .StartupPa th & "/Receiver.xml")
Dim LargestReceiverID = (From el In MyDocReceiver.Descendants( "Receiver" ) Select CInt(el.<ReceiverID>.Value )).ToList
LargestReceiverID.Sort()
Dim CheckForItem1 = (From el In MyDocReceiver.Descendants( "Receiver" ).Elements ("Name") Select el.Value).ToList
If Not CheckForItem1.Contains(Me. Textbox2.T ext.ToStri ng) Then
Dim xNew1 As XElement = New XElement("Receiver")
xNew1.Add(New XElement("ReceiverID", (LargestReceiverID.Last() + 1)))
xNew1.Add(New XElement("Name", Me.Textbox2.Text.ToString) )
MyDocReceiver.Root.Add(xNe w1)
MyDocReceiver.Save(Applica tion.Start upPath & "/Receiver.xml")
End If
If CheckForItem1.Contains(Me. Textbox2.T ext.ToStri ng) Then
Msgbox" The data already exist"
exit sub
' However need help with modifying the following code:
Dim xNew1 As XElement = New XElement("Receiver")
xNew1.Add(New XElement("ReceiverID", (Existing ID of matching record---- (.<ReceiverID>.Value))**** Does not work
xNew1.Add(New XElement("Name", Me.Textbox2.Text.ToString) )
MyDocReceiver.Root.Add(xNe w1)
MyDocReceiver.Save(Applica tion.Start upPath & "/Receiver.xml")
End If
Thanks,
Victor
The code below checks successfully for duplicates but I need to use the existing ID of the matching record insated of creating a new record. I included a messagebox to tell the user the data entered already exist, but instead of the messagebox, I would prefer to save the existing ID (ReceiverID) of the matching record to another xml file.
'Receiver()
Dim MyDocReceiver As XDocument = XDocument.Load(Application
Dim LargestReceiverID = (From el In MyDocReceiver.Descendants(
LargestReceiverID.Sort()
Dim CheckForItem1 = (From el In MyDocReceiver.Descendants(
If Not CheckForItem1.Contains(Me.
Dim xNew1 As XElement = New XElement("Receiver")
xNew1.Add(New XElement("ReceiverID", (LargestReceiverID.Last() + 1)))
xNew1.Add(New XElement("Name", Me.Textbox2.Text.ToString)
MyDocReceiver.Root.Add(xNe
MyDocReceiver.Save(Applica
End If
If CheckForItem1.Contains(Me.
Msgbox" The data already exist"
exit sub
' However need help with modifying the following code:
Dim xNew1 As XElement = New XElement("Receiver")
xNew1.Add(New XElement("ReceiverID", (Existing ID of matching record---- (.<ReceiverID>.Value))****
xNew1.Add(New XElement("Name", Me.Textbox2.Text.ToString)
MyDocReceiver.Root.Add(xNe
MyDocReceiver.Save(Applica
End If
Thanks,
Victor
ASKER
Hello,
Still can't figure out a solution, I need to somehow save the value of the ReceiverID when a duplicate is found. I believe it would be in that part of the code, but can't figure out the proper syntax.
Dim x as integer
If CheckForItem1.Contains(Me. Textbox2.T ext.ToStri ng) Then
'Set x equal to ReceiverID of element with duplicate Receiver.
x = ReceiverID.
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application .StartupPa th & "/Link.xml")
Dim LinkID = (From el In MyDocLink.Descendants("Lin k") Select CInt(el.<LinkID>.Value)).T oList
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", (x)'**** Include x in link file
MyDocLink.Root.Add(xNewLin k)
MyDocLink.Save(Application .StartupPa th & "/Link.xml")
Still can't figure out a solution, I need to somehow save the value of the ReceiverID when a duplicate is found. I believe it would be in that part of the code, but can't figure out the proper syntax.
Dim x as integer
If CheckForItem1.Contains(Me.
'Set x equal to ReceiverID of element with duplicate Receiver.
x = ReceiverID.
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application
Dim LinkID = (From el In MyDocLink.Descendants("Lin
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", (x)'**** Include x in link file
MyDocLink.Root.Add(xNewLin
MyDocLink.Save(Application
Hi vcharles,
Can u post the sample data.. along with expected output.
Sorry for the late reply.
Can u post the sample data.. along with expected output.
Sorry for the late reply.
ASKER
Hello,
Below is an example of the sample data and desired output.
Data source:
Receiver.xml:
ReceiverID = 1
Receiver = BEL
ReceiverID = 2
Receiver = CAN
ReceiverID = 3
Receiver = NLD
ReceiverID = 4
Receiver = USA
Donor.xml:
DonorID = 1
Donor = USA
DonorID = 2
Donor = ESP
DonorID = 3
Donor = CAN
DonorID = 4
Donor = DEU
DonorID = 5
Donor = NLD
Link.xml
ReceiverID = 1
DonorID = 2
ReceiverID = 1
DonorID = 1
ReceiverID = 2
DonorID = 3
ReceiverID = 3
DonorID = 4
ReceiverID = 1
DonorID = 5
A combobox displays all the receivers, and when the user selects BEL:
Desired Output:
In two Comboboxes (Receiver and Donor)
Receiver: BEL
Donor: CAN
Next Previous (Buttons)
When User clicks on [Next] he/she sees:
Receiver: BEL
Donor: USA
When User clicks on [Next] aagain he/she sees:
Receiver: BEL
Donor: NLD
The data displayed in the comboboxes depends on the IDs listed in link.xml and is filter by country selected in the combobox ( i.e. ReceiverID = 1 for BEL)
Thanks,
Victor
Below is an example of the sample data and desired output.
Data source:
Receiver.xml:
ReceiverID = 1
Receiver = BEL
ReceiverID = 2
Receiver = CAN
ReceiverID = 3
Receiver = NLD
ReceiverID = 4
Receiver = USA
Donor.xml:
DonorID = 1
Donor = USA
DonorID = 2
Donor = ESP
DonorID = 3
Donor = CAN
DonorID = 4
Donor = DEU
DonorID = 5
Donor = NLD
Link.xml
ReceiverID = 1
DonorID = 2
ReceiverID = 1
DonorID = 1
ReceiverID = 2
DonorID = 3
ReceiverID = 3
DonorID = 4
ReceiverID = 1
DonorID = 5
A combobox displays all the receivers, and when the user selects BEL:
Desired Output:
In two Comboboxes (Receiver and Donor)
Receiver: BEL
Donor: CAN
Next Previous (Buttons)
When User clicks on [Next] he/she sees:
Receiver: BEL
Donor: USA
When User clicks on [Next] aagain he/she sees:
Receiver: BEL
Donor: NLD
The data displayed in the comboboxes depends on the IDs listed in link.xml and is filter by country selected in the combobox ( i.e. ReceiverID = 1 for BEL)
Thanks,
Victor
ASKER
Please note the data sent in my previous post is actually in the proper xml format, but it was sent in the wrong format just as an example of the data it contains.
I am not able to get the relationship expected in Link.xml from the Receiver and Donor.
Please explain the logic in its construction.
ASKER
The link file holds the ID values of the Receiver and Donor files in order to avoid duplicate Receiver and Donor entries. When a user selects a Receiver and donor from a grid/dropdownlist and presses the save button, their IDs are saved in the link file. To display the data saved the IDs in the link file are used to display the combinations of Donors and receivers already saved.
Donor:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Donor>
<DonorID>1</DonorID>
<Name>BEL</Name>
</Donor>
<Donor>
<DonorID>2</DonorID>
<Name>USA</Name>
</Donor>
<Donor>
<DonorID>3</DonorID>
<Name>CAN</Name>
</Donor>
<Donor>
<DonorID>4</DonorID>
<Name>DEU</Name>
</Donor>
</Root>
Receiver:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Receiver>
<ReceiverID>1</ReceiverID>
<Name>BEL</Name>
</Receiver>
<Receiver>
<ReceiverID>2</ReceiverID>
<Name>USA</Name>
</Receiver>
<Receiver>
<ReceiverID>3</ReceiverID>
<Name>CAN</Name>
</Receiver>
<Receiver>
<ReceiverID>4</ReceiverID>
<Name>DEU</Name>
</Receiver>
</Root>
Link:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Link>
<LinkID>1</LinkID>
<ReceiverID>3</ReceiverID>
<DonorID>2</DonorID>
</Link>
<Link>
<LinkID>1</LinkID>
<ReceiverID>1</ReceiverID>
<DonorID>3</DonorID>
</Link>
<Link>
<LinkID>1</LinkID>
<ReceiverID>2</ReceiverID>
<DonorID>1</DonorID>
</Link>
</Root>
My issue is, for example, when the users insert a country in a textbox for Donor, the code checks to see if the data is already available in Donor.xml, if it does (A), I only want to pass the existing DonoID for the matching record to the link file and if it does not(B), I want to save it to the Donor.xml while creating a new ID and also save the ID created to the link.xml file. I am able to do the part(B), but can't figure out the first part(A). How do i identify the DonorD when there is a match in Part 1? Once I do, I can pass it the to link.xml file in Part 2 of my code:
Part 1:
Dim x as integer
If CheckForItem1.Contains(Me. Textbox2.T ext.ToStri ng) Then
'Set x equal to ReceiverID of element with duplicate Receiver.
x = ReceiverID.
Part 2:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application .StartupPa th & "/Link.xml")
Dim LinkID = (From el In MyDocLink.Descendants("Lin k") Select CInt(el.<LinkID>.Value)).T oList
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", (x)'**** Include x in link file
MyDocLink.Root.Add(xNewLin k)
MyDocLink.Save(Application .StartupPa th & "/Link.xml")
Thanks,
Victor
Donor:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Donor>
<DonorID>1</DonorID>
<Name>BEL</Name>
</Donor>
<Donor>
<DonorID>2</DonorID>
<Name>USA</Name>
</Donor>
<Donor>
<DonorID>3</DonorID>
<Name>CAN</Name>
</Donor>
<Donor>
<DonorID>4</DonorID>
<Name>DEU</Name>
</Donor>
</Root>
Receiver:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Receiver>
<ReceiverID>1</ReceiverID>
<Name>BEL</Name>
</Receiver>
<Receiver>
<ReceiverID>2</ReceiverID>
<Name>USA</Name>
</Receiver>
<Receiver>
<ReceiverID>3</ReceiverID>
<Name>CAN</Name>
</Receiver>
<Receiver>
<ReceiverID>4</ReceiverID>
<Name>DEU</Name>
</Receiver>
</Root>
Link:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<Link>
<LinkID>1</LinkID>
<ReceiverID>3</ReceiverID>
<DonorID>2</DonorID>
</Link>
<Link>
<LinkID>1</LinkID>
<ReceiverID>1</ReceiverID>
<DonorID>3</DonorID>
</Link>
<Link>
<LinkID>1</LinkID>
<ReceiverID>2</ReceiverID>
<DonorID>1</DonorID>
</Link>
</Root>
My issue is, for example, when the users insert a country in a textbox for Donor, the code checks to see if the data is already available in Donor.xml, if it does (A), I only want to pass the existing DonoID for the matching record to the link file and if it does not(B), I want to save it to the Donor.xml while creating a new ID and also save the ID created to the link.xml file. I am able to do the part(B), but can't figure out the first part(A). How do i identify the DonorD when there is a match in Part 1? Once I do, I can pass it the to link.xml file in Part 2 of my code:
Part 1:
Dim x as integer
If CheckForItem1.Contains(Me.
'Set x equal to ReceiverID of element with duplicate Receiver.
x = ReceiverID.
Part 2:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application
Dim LinkID = (From el In MyDocLink.Descendants("Lin
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", (x)'**** Include x in link file
MyDocLink.Root.Add(xNewLin
MyDocLink.Save(Application
Thanks,
Victor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, I don't understand that part of your code:
If Not String.IsNullOrEmpty(searc hId) Then
' Country is already present in the xml, found the id
End If
Also, can I modify my code as follows:
Dim search As String = Textbox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load("C:\Receiver.xml" )
Dim list As XmlNodeList = dom.SelectNodes("//Root/Re ceiver")
If CheckForItem1.Contains(Me. Textbox2.T ext.ToStri ng) Then
.For Each node As XmlNode In list
If node("Name").InnerText.Equ als(search ) Then
searchId = node("ReceiverrID").InnerT ext
Exit For
End If
Next
End If
Part 2:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application .StartupPa th & "/Link.xml")
Dim LinkID = (From el In MyDocLink.Descendants("Lin k") Select CInt(el.<LinkID>.Value)).T oList
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", searchId))
MyDocLink.Root.Add(xNewLin k)
MyDocLink.Save(Application .StartupPa th & "/Link.xml")
If Not String.IsNullOrEmpty(searc
' Country is already present in the xml, found the id
End If
Also, can I modify my code as follows:
Dim search As String = Textbox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load("C:\Receiver.xml"
Dim list As XmlNodeList = dom.SelectNodes("//Root/Re
If CheckForItem1.Contains(Me.
.For Each node As XmlNode In list
If node("Name").InnerText.Equ
searchId = node("ReceiverrID").InnerT
Exit For
End If
Next
End If
Part 2:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application
Dim LinkID = (From el In MyDocLink.Descendants("Lin
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", searchId))
MyDocLink.Root.Add(xNewLin
MyDocLink.Save(Application
Hi
searchId check after the loop will tell whether the search text was found in the nodes i.e the country name as "USA" is found in the xml that search can from anywhere like from text box. Set the text which u want to search (duplicate), if found in existing xml then u can perform accordingly
>>
My issue is, for example, when the users insert a country in a textbox for Donor, the code checks to see if the data is already available in Donor.xml, if it does (A), I only want to pass the existing DonorID for the matching record to the link file.
This existing donorId is what is searchId, when the searchId is empty then it was not found, else duplicate found and donor id is obtained to pass to the link file
searchId check after the loop will tell whether the search text was found in the nodes i.e the country name as "USA" is found in the xml that search can from anywhere like from text box. Set the text which u want to search (duplicate), if found in existing xml then u can perform accordingly
>>
My issue is, for example, when the users insert a country in a textbox for Donor, the code checks to see if the data is already available in Donor.xml, if it does (A), I only want to pass the existing DonorID for the matching record to the link file.
This existing donorId is what is searchId, when the searchId is empty then it was not found, else duplicate found and donor id is obtained to pass to the link file
ASKER
Hi,
I think I'm getting there, but still running into some issues, CodeA is what I'm using, problem is it does work with your CodeB because of error on line: Dim list As XmlNodeList = MyReceiver.SelectNodes("// Root/Recei ver"). Error: "Selected Nodes is not a member of System.Xml.Linq.XDocument"
CodeA:
Dim MyReceiverAs XDocument = XDocument.Load(Server.MapP ath("~/App _Data/Rece iver.xml") )
Dim LargestReceiverID = (From el In MyReceiver.Descendants("Re ceiverTabl e") Select CInt(el.<Receiver_ID>.Valu e)).ToList
LargestReceiverID.Sort()
Dim CheckForItemC = (From el In MyReceiver.Descendants("Re ceiverTabl e").Elemen ts("Receiv er") Select el.Value).ToList
If Not CheckForItemC.Contains(Me. TextBox2.T ext.ToStri ng) Then
Dim xNewA As XElement = New XElement("ReceiverTable")
xNewA.Add(New XElement("Receiver_ID", (LargestReceiverID.Last() + 1)))
xNewA.Add(New XElement("Receiver", Me.TextBox2.Text.ToString) )
MyReceiver.Root.Add(xNewA)
MyNSN.Save(Server.MapPath( "~/App_Dat a/Receiver .xml"))
End If
CodeB: Duplicates
Dim searchId As String = Nothing
' Dim dom As New XmlDocument() 'Already declared
'dom.Load("C:\Receiver.xml ")
Dim list As XmlNodeList = MyReceiver.SelectNodes("// Root/Recei ver") ****Error
If CheckForItemC.Contains(Me. TextBox2.T ext.ToStri ng) Then 'Duplicates
For Each node As XmlNode In list
If node("Name").InnerText.Equ als(search ) Then
searchId = node("ReceiverID").InnerTe xt
Exit For
End If
Next
MsgBox(searchId)
End If
searcid is then passed to Link.xml with CodeC
CodeC:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application .StartupPa th & "/Link.xml")
Dim LinkID = (From el In MyDocLink.Descendants("Lin k") Select CInt(el.<LinkID>.Value)).T oList
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
If CheckForItemC.Contains(Me. TextBox2.T ext.ToStri ng) then
xNewLink.Add(New XElement("ReceiverID", searchId))
Endif
If Not CheckForItemC.Contains(Me. TextBox2.T ext.ToStri ng) Then
xNewLink.Add(New XElement("ReceiverID", (LargestReceiverID.Last() + 1)))
End If
MyDocLink.Root.Add(xNewLin k)
MyDocLink.Save(Application .StartupPa th & "/Link.xml")
I think I'm getting there, but still running into some issues, CodeA is what I'm using, problem is it does work with your CodeB because of error on line: Dim list As XmlNodeList = MyReceiver.SelectNodes("//
CodeA:
Dim MyReceiverAs XDocument = XDocument.Load(Server.MapP
Dim LargestReceiverID = (From el In MyReceiver.Descendants("Re
LargestReceiverID.Sort()
Dim CheckForItemC = (From el In MyReceiver.Descendants("Re
If Not CheckForItemC.Contains(Me.
Dim xNewA As XElement = New XElement("ReceiverTable")
xNewA.Add(New XElement("Receiver_ID", (LargestReceiverID.Last() + 1)))
xNewA.Add(New XElement("Receiver", Me.TextBox2.Text.ToString)
MyReceiver.Root.Add(xNewA)
MyNSN.Save(Server.MapPath(
End If
CodeB: Duplicates
Dim searchId As String = Nothing
' Dim dom As New XmlDocument() 'Already declared
'dom.Load("C:\Receiver.xml
Dim list As XmlNodeList = MyReceiver.SelectNodes("//
If CheckForItemC.Contains(Me.
For Each node As XmlNode In list
If node("Name").InnerText.Equ
searchId = node("ReceiverID").InnerTe
Exit For
End If
Next
MsgBox(searchId)
End If
searcid is then passed to Link.xml with CodeC
CodeC:
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application
Dim LinkID = (From el In MyDocLink.Descendants("Lin
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
If CheckForItemC.Contains(Me.
xNewLink.Add(New XElement("ReceiverID", searchId))
Endif
If Not CheckForItemC.Contains(Me.
xNewLink.Add(New XElement("ReceiverID", (LargestReceiverID.Last() + 1)))
End If
MyDocLink.Root.Add(xNewLin
MyDocLink.Save(Application
ASKER
I tried the following code, but eventhougfh duplicate is found, searchId is returned blank with the messagebox listed at the end of the code..
Dim search As String = TextBox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load(Server.MapPath("~ /App_Data/ Receiver.x ml"))
Dim list As XmlNodeList = dom.SelectNodes("//Root/Re ceiverr")
If CheckForItem.Contains(Me.T extBox2.Te xt.ToStrin g) Then
For Each node As XmlNode In list
If node("Receiver").InnerText .Equals(se arch) Then
searchId = node("Receiver_ID").InnerT ext
Exit For
End If
Next
MsgBox(searchId)
End If
Dim search As String = TextBox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load(Server.MapPath("~
Dim list As XmlNodeList = dom.SelectNodes("//Root/Re
If CheckForItem.Contains(Me.T
For Each node As XmlNode In list
If node("Receiver").InnerText
searchId = node("Receiver_ID").InnerT
Exit For
End If
Next
MsgBox(searchId)
End If
ASKER
Hi,
I modified my code to match the latest Receiver.xml format below but I receiveD the following
error: Object reference not set to an instance of an object.
on line:: If node("Receiver").InnerText .Equals(se arch) Then
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<ReceiverTable>
<Receiver_ID>1</Receiver_I D>
<Receiver>USA</Receiver>
</ReceiverTable>
</Root>
Code modified with "ReceiverTable":
Dim search As String = TextBox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load(Server.MapPath("~ /App_Data/ Receiver.x ml"))
Dim list As XmlNodeList = dom.SelectNodes("//Receive rTable/Rec eiverr") ***Modified
If CheckForItem.Contains(Me.T extBox2.Te xt.ToStrin g) Then
For Each node As XmlNode In list
If node("Receiver").InnerText .Equals(se arch) Then
searchId = node("Receiver_ID").InnerT ext
Exit For
End If
Next
MsgBox(searchId)
End If
I modified my code to match the latest Receiver.xml format below but I receiveD the following
error: Object reference not set to an instance of an object.
on line:: If node("Receiver").InnerText
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
<ReceiverTable>
<Receiver_ID>1</Receiver_I
<Receiver>USA</Receiver>
</ReceiverTable>
</Root>
Code modified with "ReceiverTable":
Dim search As String = TextBox2.Text
Dim searchId As String = Nothing
Dim dom As New XmlDocument()
dom.Load(Server.MapPath("~
Dim list As XmlNodeList = dom.SelectNodes("//Receive
If CheckForItem.Contains(Me.T
For Each node As XmlNode In list
If node("Receiver").InnerText
searchId = node("Receiver_ID").InnerT
Exit For
End If
Next
MsgBox(searchId)
End If
Hi,
The xml node list should select ReceiverTable nodes not the Receiver nodes.
Dim list As XmlNodeList = dom.SelectNodes("//Receive rTable")
The xml node list should select ReceiverTable nodes not the Receiver nodes.
Dim list As XmlNodeList = dom.SelectNodes("//Receive
ASKER
Ii worked. Thanks!!!
ASKER
This is a better example of what I'm trying to do: I need help on the following line to add the ReceiverID that was found for the duplicate record:
xNewLink.Add(New XElement("ReceiverID", (el.<ReceiverID>.Value)))'
Code:
'Receiver()
Dim MyDocReceiver As XDocument = XDocument.Load(Application
Dim LargestReceiverID = (From el In MyDocReceiver.Descendants(
LargestReceiverID.Sort()
Dim CheckForItem1 = (From el In MyDocReceiver.Descendants(
If Not CheckForItem1.Contains(Me.
Dim xNew1 As XElement = New XElement("Receiver")
xNew1.Add(New XElement("ReceiverID", (LargestReceiverID.Last() + 1)))
xNew1.Add(New XElement("Name", Me.Textbox2.Text.ToString)
MyDocReceiver.Root.Add(xNe
MyDocReceiver.Save(Applica
End If
If CheckForItem1.Contains(Me.
Add already existed ReceiverID to Link.xml file.
'Link
Dim MyDocLink As XDocument = XDocument.Load(Application
Dim LinkID = (From el In MyDocLink.Descendants("Lin
LinkID.Sort()
Dim xNewLink As XElement = New XElement("Link")
xNewLink.Add(New XElement("LinkID", (LinkID.Last() + 1)))
xNewLink.Add(New XElement("ReceiverID", (el.<ReceiverID>.Value)))'
MyDocLink.Root.Add(xNewLin
MyDocLink.Save(Application
Thanks,
Victor