Hi Guys,
I have an XML fileI need a way to search the XML file for a DVDTitle the title I want it to find is held within a textbox, and ammend the <copies> +1 and <rental> -1 nods when I click on a button .Code:<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>
Heres the vb code I've got so far, the code was ammended from nmadd's thread
http://www.vbforums.com/showthread.php?t=478692
The vb code I have is the following:
I dont know how to tell to get the dvd title from the textbox, the current line I have isCode:Dim xd As New XmlDocumen Dim nod As XmlNode = xd.SelectSingleNode("/DVDInfo/DVD/DVDTitle"(Me.DVD_Title.text)) xd.Load("C:\Documents and Settings\Huw Friedhoff\Desktop\Project Interface9\Project interface\DVD.xml") If Me.CopiesTextBlock.Text = "0" Then MessageBox.Show("No copies available for Rent") ElseIf nod IsNot Nothing Then nod.ChildNodes(5).InnerText = nod.ChildNodes(5).Innertext - 1 nod.Childnodes(6).InnerText = nod.ChildNodes(6).Innertext + 1 Else Messagebox.show("Could not find the DVD you requested") End If xd.Save("C:\Documents and Settings\Huw Friedhoff\Desktop\Project Interface9\Project interface\DVD.xml") MessageBox.Show("Changes have been made to the file")
Code:Dim nod As XmlNode = xd.SelectSingleNode("/DVDInfo/DVD/DVDTitle"(Me.DVD_Title.text))
Any help would be appriciated,
Rusty.




Reply With Quote