Try
If Open.ShowDialog = DialogResult.OK Then
objTxtRd = New XmlTextReader(Open.FileName)
While (objTxtRd.Read())
If (objTxtRd.NodeType = XmlNodeType.Element) Then
If (objTxtRd.HasAttributes) Then
ListBox1.Items.Add("The Element " & objTxtRd.Name.ToString & " has " _
& objTxtRd.AttributeCount.ToString & " Attributes ")
ListBox1.Items.Add("The Attributes Are : ")
While (objTxtRd.MoveToNextAttribute())
ListBox1.Items.Add(objTxtRd.Name & " = " & objTxtRd.Value)
End While
Else
ListBox1.Items.Add("The Element " & objTxtRd.Name & " Has No Attributes.")
End If
ListBox1.Items.Add("")
End If
End While
End If
Catch err As Exception
errmsg = errmsg + "Error Occured While Reading" & strFilePath & " " & err.ToString()
ListBox1.Items.Add(errmsg)
Finally
If Not objTxtRd Is Nothing Then
objTxtRd.Close()
End If
End Try