kdtupj8lor
New Member
I am pretty new to Visual Basic so I want to excuse myself right from the beginning. The code below is supposed to get a node list with all nodes where the \[code\]InnerText\[/code\] of \[code\]Name\[/code\] is equal to the String named \[code\]membername\[/code\]. This part seems to work perfectly, but afterwards I also want to check whether in this list a node \[code\]Logout\[/code\] already exists. This way I want to prevent duplicating the data in the xml database. Unfortunately it doesn't work the way I tried it. It keeps duplicating all the data. So what's my mistake??XML FILE\[code\]<?xml version="1.0" encoding="utf-16"?><Times> <Shift> <Name>Philipp</Name> <Login>14:11</Login> <Date>25.03.2013</Date> <Logout>14:11</Logout> ' Don't generate again .... </Shift> <Shift> <Name>Philipp</Name> <Login>14:11</Login> <Date>25.03.2013</Date> <Logout>14:11</Logout> ' Generate Logout node </Shift></Times>\[/code\]VISUAL BASIC CODE\[code\] If File.Exists(Filename) Then DOMDocument.Load(Filename) Dim RootElement As XmlElement = DOMDocument.DocumentElement Dim ListOfTitles As XmlNodeList = DOMDocument.GetElementsByTagName("Name") For Each Node As XmlNode In ListOfTitles If Node.InnerText = memberName Then Dim logout = Node.SelectNodes("Logout") If Not logout Is Nothing Then Dim NewElement As XmlElement = DOMDocument.CreateElement("Logout") NewElement.InnerText = DateTime.Now.ToShortTimeString() Dim Parent As XmlNode = Node.ParentNode Parent.AppendChild(NewElement) DOMDocument.Save(Filename) End If End If Next End If\[/code\]