Error while reading xml file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I've got a little problem with reading a xml file. I tried to converte the
following code from c to cv.NET

Public Sub New()
If Not File.Exists(conf_path) Then
MsgBox("Configuration file cannot be found")
Application.Exit()
Else
Try
Dim xDoc As System.Xml.XmlDocument
xDoc.Load(conf_path) '<- ERROR
Dim xRoot As System.Xml.XmlElement = xDoc.DocumentElement
Dim nodeList As System.Xml.XmlNodeList =
xRoot.ChildNodes.Item(0).ChildNodes
'Load data into Name Value Collection
conf_values.Add("Password",
nodeList.Item(0).Attributes(1).Value)
Catch ex As Exception
MsgBox("Error in configuration file (" & conf_path & ")
" & ex.ToString)
Application.Exit()
End Try
End If
End Sub

The file exsits, but I get a SystemNullReference whith:

xDoc.Load(conf_path)

Can somebody tell me why?

Thx,
Cyberdot
 
Wouldn't it be nice to create an instance of XmlDocument first?

Dim xDoc As New System.Xml.XmlDocument
 
Back
Top