Error while reading xml file

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
 
A

Alex Feinman [MVP]

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

Dim xDoc As New System.Xml.XmlDocument
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XML insert element to a certain nested child 4
read xml file nodes 2
Parsing XML file 3
Reading XML 1
Error :XML not defined 1
VB and XML question 4
Reading XML with VB.NET 1
Reading XML file getting error 3

Top