Hi all,
I'm trying to create a custom function to return vehicle information, using an webservice. When calling the function, I want to provide 2 parameters: 1 for the vehicle plate number and 1 for the dataset type.
The online service provides different datasets for different kind of vehicle information (general info, fuel info, axes info, etc)
What I would like to know is this. Is it possible to let the function display the possible options? Showing, or even selecting, the dataset that I want to use?
I have the following code right now:
The strType parameter should display the possible dataset options as defined in the Select Case statement. Allowing me to simply select which dataset to use instead of having to type the exact naming... Is this possible?
I'm trying to create a custom function to return vehicle information, using an webservice. When calling the function, I want to provide 2 parameters: 1 for the vehicle plate number and 1 for the dataset type.
The online service provides different datasets for different kind of vehicle information (general info, fuel info, axes info, etc)
What I would like to know is this. Is it possible to let the function display the possible options? Showing, or even selecting, the dataset that I want to use?
I have the following code right now:
Code:
Function GetVehicleDetails(strType As String, strPlate As String) As String
'Create required variables
Dim xmldoc As MSXML2.DOMDocument60
Dim xmlNodeList As MSXML2.IXMLDOMNodeList
Dim xmlNode As MSXML2.IXMLDOMNode
Dim myNode As MSXML2.IXMLDOMNode
'Determine which dataset to be used
Dim strDataset As String
Select Case strType
Case "Voertuig informatie"
strDataset = "m9d7-ebf2.xml"
Case "Assen"
strDataset = "3huj-srit.xml"
Case "Brandstof"
strDataset = "8ys7-d773.xml"
Case "Carrosserie"
strDataset = "vezc-m2t6.xml"
Case "Carrosserie_specifiek"
strDataset = "jhie-znh9.xml"
Case "Voertuigklasse"
strDataset = "kmfi-hrps.xml"
End Select
'Assemble the query string
Dim strQuery As String
strQuery = "https://opendata.rdw.nl/resource/"
strQuery = strQuery & strDataset
strQuery = strQuery & "?kenteken=" & Replace(UCase(strPlate), "-", "")
'define XML and HTTP components
Dim xmlService As New MSXML2.XMLHTTP60
xmlService.Open "GET", strQuery, False
xmlService.Send
Set xmldoc = New MSXML2.DOMDocument60
xmldoc.async = False
xmldoc.LoadXML (xmlService.responseText)
Set xmlNodeList = xmldoc.getElementsByTagName("*")
For Each xmlNode In xmlNodeList
For Each myNode In xmlNode.childNodes
If myNode.NodeType = NODE_TEXT Then
Debug.Print xmlNode.nodeName & "=" & xmlNode.Text
End If
Next myNode
Next xmlNode
Set xmldoc = Nothing
End Function
The strType parameter should display the possible dataset options as defined in the Select Case statement. Allowing me to simply select which dataset to use instead of having to type the exact naming... Is this possible?