To download NI software, including the products shown below, visit ni.com/downloads.
1. Overview
This example VI creates a Google Maps API URL for a specified address, and returns its XML content using an HTTP method.
2. Description
Using the Google Maps API Subset shown here to build up the URL string, you can easily get the Latitude and Longitude and view other data by entering an address into this VI. This could be further expanded to read back this XML data via DataSockets for parsing, and even then using those parameters to automatically show the location via Google Earth.
This example also uses the HTTP method GET in LabVIEW to get the URL's content. Use this example to understand how to fetch the content of simple URL's.
3. Requirements
NI LabVIEW Base Development System 2012 (or compatible).
4. Steps to Implement or Execute Code
5. Additional Information or References
Searching a few parameters for National Instruments UK Office returns the following XML:
{Description-Separate-2
"status": "OK",
"results": [ {
"types": [ "locality", "political" ],
"formatted_address": "Newbury, Berkshire, UK",
"address_components": [ {
"long_name": "Newbury",
"short_name": "Newbury",
"types": [ "locality", "political" ]
}, {
"long_name": "West Berkshire",
"short_name": "West Berkshire",
"types": [ "administrative_area_level_3", "political" ]
}, {
"long_name": "West Berkshire",
"short_name": "West Berkshire",
"types": [ "administrative_area_level_2", "political" ]
}, {
"long_name": "England",
"short_name": "England",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "United Kingdom",
"short_name": "GB",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": 51.4003873,
"lng": -1.3218591
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": 51.3864628,
"lng": -1.3538739
},
"northeast": {
"lat": 51.4143075,
"lng": -1.2898443
}
},
"bounds": {
"southwest": {
"lat": 51.3671040,
"lng": -1.3532450
},
"northeast": {
"lat": 51.4145500,
"lng": -1.2881960
}
}
},
"partial_match": true
} ]
}
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
A few areas of improvement:
Hi!
I just wanted to let people reading this know, that JSON to XML conversion can be achieved fairly simpy. I wrote a document, where I use JSON-XML conversion. It probably worth to read and watch the code.
Peter