I need to download an xml
file from web, read it and insert the data into MS SQL
server table.
I was quite successful using this guide (VBA + Access forms)
Unfortunately, I cannot use this solution as the client would need to have MS Access (doesn't work in runtime mode for some reason) installed and even then with VBA I have some other issues and so on.
Is there anyone that can help me convert this code to VB.net
- I'm building a small app in Visual Studio. I have even tried from scratch but this XML is a bit strange.
EDIT: Thanks to rskar, i have tried from the link he provided and thus far was able to repeat the results from the example xml but i cannot do for my xml. My progress bellow (ignore some of the comments from source code sample):
Public Sub Main()
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
'Create the XML Document
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load("C:\CurrencyImport\Temp\eurofxref-daily.xml")
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/gesmes:Envelope/Cube/Cube/Cube")
'Loop through the nodes
For Each m_node In m_nodelist
'Get the Gender Attribute Value
Dim genderAttribute = m_node.Attributes.GetNamedItem("currency").Value
MsgBox(genderAttribute)
Next
Catch errorVariable As Exception
'Error trapping
Console.Write(errorVariable.ToString())
End Try
End Sub
EDIT: When I "cleaned" the original xml of the node "gesmes:envelope" and changed the m_nodelist = m_xmld.SelectNodes("/Cube/Cube/Cube") like so, it works but i can't get it to work with the original xml ... Probably something with the sintax of the node path.
SOLUTION: this is a solution for the xpath: m_nodelist = m_xmld.SelectNodes("//*[@currency]"). Didn't find any other way to get it working with the original file.