New to VB.NET and I can't find a way to retrieve element attributes by name. The exam responses (exresp) have attributes Question Number (qnum) and others but my attempt to read qnum is failing. Any help is appreciated.
Public Function PostExamData(ByVal dataPacket As XmlDocument) As String
Dim nodeList As XmlNodeList, node As XmlNode
...
' get list of response elements from xml document
nodeList = dataPacket.DocumentElement.GetElementsByTagName("exresp")
For Each node In nodeList
Return node.Attributes("qnum").Value ' <=== fails on "Object reference not set to an instance of an object."
...
Public Function PostExamData(ByVal dataPacket As XmlDocument) As String
Dim nodeList As XmlNodeList, node As XmlNode
...
' get list of response elements from xml document
nodeList = dataPacket.DocumentElement.GetElementsByTagName("exresp")
For Each node In nodeList
Return node.Attributes("qnum").Value ' <=== fails on "Object reference not set to an instance of an object."
...