We offer example source code for the most requested programming languages; however, if you still need assistance, contact us and we may be able to point you in the right direction.
https://dotnetfiddle.net/YPyzIN
// variables XmlDocument States = new XmlDocument(); string Url = "https://mysafeinfo.com/api/data?list=states&format=xml&case=lower&alias=statename=name,abbreviation=code,statehood=year&exclude=id&token=test"; // request States.Load(Url); // iterate states collection foreach (XmlElement s in States.SelectNodes("//s")) { Console.WriteLine(string.Format("{0}, {1}, {2}, {3}", s.GetAttribute("name"), s.GetAttribute("code"), s.GetAttribute("capital"), s.GetAttribute("year"))); }
https://dotnetfiddle.net/3Dw4j1
'variables Dim States As New XmlDocument() Dim Url As String = "https://mysafeinfo.com/api/data?list=states&format=xml&case=lower&alias=statename=name,abbreviation=code,statehood=year&exclude=id&token=test" 'request States.Load(Url) 'iterate states collection For Each s As XmlElement In States.SelectNodes("//s") Console.WriteLine(String.Format("{0}, {1}, {2}, {3}", s.GetAttribute("name"), s.GetAttribute("code"), s.GetAttribute("capital"), s.GetAttribute("year"))) Next
https://dotnetfiddle.net/CyYOqQ
// variables string Result = string.Empty; string Url = "https://mysafeinfo.com/api/data?list=states&format=json&case=lower&alias=statename=name,abbreviation=code,statehood=year&exclude=id&token=test"; List<State> States = new List<State>(); // request using (WebClient client = new WebClient()) { // specify encoding client.Encoding = System.Text.UTF8Encoding.UTF8; // download data Result = client.DownloadString(Url); } // use Json.NET (Newtonsoft.Json) to deserialize json string into a strongly typed list of states // https://www.nuget.org/packages/Newtonsoft.Json States = Newtonsoft.Json.JsonConvert.DeserializeObject<List<State>>(Result); // iterate states collection foreach (State s in States) { Console.WriteLine(string.Format("{0}, {1}, {2}, {3}", s.name, s.code, s.capital, s.year)); } // state class public class State { public string name = string.Empty; public string code = string.Empty; public string capital = string.Empty; public string year = string.Empty; }
import java.io.*; import java.net.URL; public class ReadCSV { // url to web service final static String webSiteURL = "https://mysafeinfo.com/api/data?list=presidents&format=csv"; // outfile file path final static String rawFileName = "c:\\temp\\presidents.csv"; // main public static void main(String[] args) { // fetch our data and create a CSV file fetchData(webSiteURL); } // fetch data from web in CSV format private static void fetchData(String siteURL) { try { // open output file PrintWriter pw = new PrintWriter(rawFileName); // define URL using website address URL serviceURL = new URL(siteURL); // define an input stream and reader InputStream is = serviceURL.openStream(); InputStreamReader isr = new InputStreamReader(is, "UTF-8"); // buffered reader let us read and process chunks of data at time BufferedReader br = new BufferedReader(isr); // create a variable to hold the contents from the buffer StringBuffer response = new StringBuffer(); // fetch the next chunk of content String nextLineFromService = br.readLine(); // keep reading and appending to the buffer while (nextLineFromService != null) { // to see what we are doing in the console System.out.println(nextLineFromService); // output line to file pw.println(nextLineFromService); nextLineFromService = br.readLine(); } // dump the buffer to our content variable isr.close(); pw.close(); } catch (Exception e) { System.out.println(e); } } }