BlackCell1984 Posted July 6, 2006 Posted July 6, 2006 i have writen a write XML sub Private Sub WriteOpts_XML() Dim XMLobj As Xml.XmlTextWriter Dim ue As New System.[Text].UnicodeEncoding XMLobj = New Xml.XmlTextWriter("Opts.xml", ue) XMLobj.Formatting = Xml.Formatting.Indented XMLobj.Indentation = 3 XMLobj.WriteStartDocument() XMLobj.WriteStartElement("EthylOpts") XMLobj.WriteAttributeString("PunishValue", cmbPun.SelectedIndex) XMLobj.WriteAttributeString("BanSetValue", cmbBan.SelectedIndex) XMLobj.WriteStartElement("Options") XMLobj.WriteAttributeString("Nickname", CFNick.Text) XMLobj.WriteAttributeString("PunishTime", txtpun.Text) XMLobj.WriteAttributeString("BanSettings", txtban.Text) XMLobj.WriteEndElement() XMLobj.Close() EndSub it gives out this XML file <?xml version="1.0" encoding="utf-16"?> <EthylOpts PunishValue="6" BanSetValue="2"> <Options Nickname="BlackCell" PunishTime="TextBox1" BanSettings="TextBox1" /> </EthylOpts> now i cant get s read XML to read the XML file and put those values and text where they are supposed to be. Quote
Cags Posted July 6, 2006 Posted July 6, 2006 Something like the following should work for you, it is however by no means the only way of doing it. I'm a C# user myself, hopefully I translated it to vb correctly. Dim reader As New System.Xml.XmlTextReader("path") While reader.Read() If reader.NodeType = System.Xml.XmlNodeType.Element Then If reader.Name = "EthylOpts" Then cmbPun.SelectedIndex = Single.Parse(reader.GetAttribute("PunishValue")) cmbBan.SelectedIndex = Single.Parse(reader.GetAttribute("BanSetValue")) ElseIf reader.Name = "Options" Then CFNick.Text = reader.GetAttribute("NickName") txtpun.Text = reader.GetAttribute("PunishTime") txtban.Text = reader.GetAttribute("BanSettings") End If End If End While Quote Anybody looking for a graduate programmer (Midlands, England)?
BlackCell1984 Posted July 6, 2006 Author Posted July 6, 2006 Coolz thanks i had to change a couple things but nice one thanks :D Quote
teixeira Posted July 9, 2006 Posted July 9, 2006 Hi, You could simple load XML file into a dataset. Dim ds as New DataSet; ds.ReadXml("path") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.