0

Variable 'loNode' is used before it has been assigned a value. A null reference exception could result at runtime.


does anyone know why I am getting this error?

Imports System.Xml
Module Module1

    Sub Main()
        Dim doc As New XmlDocument
        Dim loNode As XmlNode
        Dim nodes As XmlNodeList
        doc.Load("C:\Desktop\Template.xml")
        nodes = doc.SelectNodes("program/databaseinfo")
        loNode.SelectSingleNode("programshortname").InnerText = "PCF"
        doc.Save("C:\New.xml")

        loNode = Nothing
        doc = Nothing

    End Sub

End Module
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sandeepparekh9
0

in line 10 you use an attribute of loNode. Where did you set loNode to anything?

Edited by Momerath: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.