Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic question xmldocument and asp.net

Status
Not open for further replies.

edelwater

Programmer
Jun 29, 2000
203
EU
why do i get "System.NullReferenceException: Object reference not set to an instance of an object"

on this :

Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument()

If System.IO.File.Exists(Server.MapPath("/test.xml")) Then
doc.Load(Server.MapPath("/test.xml"))
Dim root As System.Xml.XmlNode = doc.DocumentElement
Else
Dim root As System.Xml.XmlNode = doc.DocumentElement

Dim comments As System.Xml.XmlElement = doc.CreateElement ("testa")
root.AppendChild(comments)
End If

?? ( on the line root.Appendcild(comments) ?)

Edward@de-leau.com
 
sorry already found out, should be :

Dim root As System.Xml.XmlNode = doc.CreateElement("Comments")
doc.AppendChild(root)

Dim filename As System.Xml.XmlElement = doc.CreateElement("Filename")
...etc... Edward@de-leau.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top