Hello,
I'm trying to enter new information in a specific node in a xml file. This is the structure of the xml file:
<Root>
<Title 1></Root>
<Title 2></Title 2></Title 1>
How would I update <Title 2></Title 2> field?
Thanks in advance.
Printable View
Hello,
I'm trying to enter new information in a specific node in a xml file. This is the structure of the xml file:
<Root>
<Title 1></Root>
<Title 2></Title 2></Title 1>
How would I update <Title 2></Title 2> field?
Thanks in advance.
This was created in VS2008, should work just fine in VS2010.
Create a file called Books.xml in the executable folder.
Add this codeCode:<?xml version="1.0" encoding="utf-8"?>
<Root>
<Titles>
<Title Name="1">I love .NET</Title>
<Title Name="2">I Love Delphi</Title>
</Titles>
</Root>
Code:Private Sub UpdateXmlItem()
Dim Doc = XDocument.Load("Books.xml")
Dim query = From items In Doc...<Title> Where items.@Name = "2"
If query.Value = "Bye Bye Delphi" Then
Console.WriteLine("You already said good bye")
Else
Console.WriteLine(query.Value)
query.Value = "Bye Bye Delphi"
Console.WriteLine(query.Value)
Doc.Save("Books.xml")
End If
End Sub