Updating an XML file in VB.net

H

huwfriedhoff

Hi Guys,

I have a friend who is developing a dvd store in Visual basic ( It's a
WPF application) and stores the data in an XML file.

the content of the XML look like this:

<DVDInfo>
<DVD>
<DVDTitle>The Exorcist</DVDTitle>
<Director>William Friedkin</Director>
<Cast>Linda Blair</Cast>
<Description>Horror</Description>
<Rating>18</Rating>
<Cost>7.99</Cost>
<Copies>0</Copies>
<Rental>0</Rental>
<Image>Exorcist.jpeg</Image>
</DVD>
<DVD>
<DVDTitle>The Matrix</DVDTitle>
<Director>Wachowski</Director>
<Cast>Keanu Reaves</Cast>
<Description>Action</Description>
<Rating>15</Rating>
<Cost>7.99</Cost>
<Copies>20</Copies>
<Rental>0</Rental>
<Image>Matrix.jpeg</Image>
</DVD>
<DVD>
<DVDTitle>The Sahara</DVDTitle>
<Director>Breck Eisner</Director>
<Cast>Matthew McConaughey</Cast>
<Description>Action</Description>
<Rating>12</Rating>
<Cost>8.99</Cost>
<Copies>20</Copies>
<Rental>0</Rental>
<Image>sahara.jpeg</Image>
</DVD>
<DVD>
<DVDTitle>Constantine</DVDTitle>
<Director>Francis Lawrence</Director>
<Cast>Keanu Reaves</Cast>
<Description>Horror</Description>
<Rating>15</Rating>
<Cost>5.99</Cost>
<Copies>20</Copies>
<Rental>0</Rental>
<Image>Constantine.jpeg</Image>
</DVD>
</DVDInfo>

He needs a way to update the file so he can add other DVD's into the
file from a form in vb

He has a Textbox input for each node from DVD title through to Image
and a button on the form.

I had thought of using the XMLreader and XMLWriter within VB but don't
know how to go about it.

Can someone help?

thanks guys,
 
M

Martin Honnen

He needs a way to update the file so he can add other DVD's into the
file from a form in vb

He has a Textbox input for each node from DVD title through to Image
and a button on the form.

I had thought of using the XMLreader and XMLWriter within VB but don't
know how to go about it.

You can use System.Xml.XmlDocument
(<URL:http://msdn2.microsoft.com/en-us/library/20esef39(VS.80).aspx>)
for that or with .NET 3.5 there is also LINQ to XML
(System.Xml.Linq.XDocument/XElement)
<URL:http://msdn2.microsoft.com/en-us/library/bb387098.aspx>.
And there is XML serialization/deserialization, that way you deal with
..NET objects in your code and the XML is created or parsed by
XmlSerializer. See
<URL:http://msdn2.microsoft.com/en-us/library/90c86ass(VS.80).aspx>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top