I would like to place an if condition within the sub that will tell it to run when the xml node STORE with attribute TEST=’test.doc’ does not exist. Any suggestions would be great. I’m new to vb.
Sub InsertNode(ByVal doc As XmlDocument) Dim City As XmlNode = doc.DocumentElement Dim Location As XmlElement = doc.CreateElement('store') Location.SetAttribute('test', 'test.doc') Dim books As XmlElement = doc.CreateElement('books') books.InnerXml = 'New Words' Location.AppendChild(books) City.AppendChild(store) End Sub 'InsertNode
Sample of the XML file
<city> <store test='test.doc'> <books> 'New Words' </books> </store> </city>
Try something like that :