Created
May 14, 2016 09:12
-
-
Save IT-Berater/3e00dc4c4c3402e0a784d8b429db4dc4 to your computer and use it in GitHub Desktop.
REST Abfrage Beispiel mit JDOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Abfrage { | |
// URL des Feeds aller Flugzeuge in Hannover von Thomas Wenzlaff. // | |
private final static String FLUGZEUG_URL = "https://api.thingspeak.com/channels/44177/feeds/last.xml"; | |
/** | |
* Start Methode. | |
* | |
* @param args | |
* keine. | |
* @throws JDOMException | |
* @throws IOException | |
*/ | |
public static void main(String[] args) throws JDOMException, IOException { | |
String result = ClientBuilder.newClient().target(FLUGZEUG_URL).request().get(String.class); | |
// result get sample: | |
// <?xml version="1.0" encoding="UTF-8"?> | |
// <feed> | |
// <created-at type="dateTime">2016-05-13T12:20:01Z</created-at> | |
// <entry-id type="integer">79166</entry-id> | |
// <field1>18</field1> | |
// <id type="integer" nil="true"/> | |
// </feed> | |
String field1 = new SAXBuilder().build(new StringReader(result)).getDocument().getRootElement().getChild("field1").getText(); | |
System.out.println("Aktuelle Anzahl Flugzeuge in Langenhagen: " + field1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment