XML XPath search in vb.net
-
Hi All, I posted this under XML but after reading some of the other posts, it was probably the wrong message board so here it is. OK I have worked out the below code to return the 'EN' string if I supply the string code, say "1000" of the below XML file but what I need to know is how to search for the string and return the string code. If I could use a wildcard in this it would be great. Any Thoughts??? Private Sub XPathSearch(ByVal XMLPath As String) Dim xmlNI As XPathNodeIterator Dim xpathDoc As XPathDocument Dim xmlNav As XPathNavigator Try xpathDoc = New XPathDocument(XMLPath) xmlNav = xpathDoc.CreateNavigator() xmlNI = xmlNav.Select("/MOMLANG/STRING[@code='" & stringValue & "']/LANG[@code='EN']") While (xmlNI.MoveNext()) 'Me.RichTextBox1.AppendText(xmlNI.Current.Name + " : " + xmlNI.Current.Value & vbCrLf) Me.RichTextBox1.AppendText("String value: " + xmlNI.Current.Value & vbCrLf) End While Catch ex As XPathException System.Console.WriteLine("XMLException: " + ex.Message) Catch ex As Exception System.Console.WriteLine("Exception: " + ex.Message) End Try End Sub I have worked with reading simple XML elements but have not worked with atributes and the like. I am also new to both XML and Dev in general. I have read several articles but most give me examples for reading simple XML e.g. John Smith The file I am trying to read is below, any help would be great and examples are very much welcome. My goal for the GUI in VB.NET will be to have a textbox to enter string number I am searching for and a dropdown but to select the language. Regards Jason Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Access Allowed List Lista de accesos permitidos Pääsylista sallitut Liste des accès autorisés Access Allowed List Hozzáférés Engedély Lista Elenco accessi consentiti