Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm having a problem reading an xml file.

 

<?xml version="1.0" encoding="utf-8"?>
<Configuration>
  <Server>
      <name>(local)</name>
  </Server>
</Configuration>

 

I'm using the following code but it's giving me an error on the readSettingsInfo.ReadStartElement("Server") line of code. Could someone please point out what I am doing wrong or if there is a better way?

 

Dim readSettingsInfo As Xml.XmlTextReader
       Dim server As String

       readSettingsInfo = New Xml.XmlTextReader(Application.StartupPath & "\settings.xml")
       readSettingsInfo.Read()
       readSettingsInfo.ReadStartElement("Configuration")
       Do While (True)
           readSettingsInfo.ReadStartElement("Server")
           server = readSettingsInfo.ReadElementString()
           readSettingsInfo.ReadEndElement()
       Loop
       readSettingsInfo.ReadEndElement()
       readSettingsInfo.Close()
       MsgBox(server)

 

cheers

 

simon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...