This is a Sample XML file which we want to read from code :
Write below function to read data from file :
Public Sub ReadFromXML()
Dim _FilePath As String
Dim _dir As New DirectoryInfo(Application.StartupPath + "\DownloadXML")
For Each _file As FileInfo In _dir.GetFiles("*.*")
_FilePath = Application.StartupPath + "\DownloadXML\" + _file.Name.ToString
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load(_FilePath)
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/XMLInfo/Info")
For Each m_node As XmlNode In m_nodelist
Dim Name As String = m_node.Attributes.GetNamedItem("Name").Value
Dim Address As String = m_node.Attributes.GetNamedItem("Address").Value
Next
Next
End Sub
No comments:
Post a Comment