I checked your sketch and changed some lines (Fixed IP, Server IP, Serial Begin)
Here is a working version. See the result in the serial monitor:
worldweatheronline-xml by Arduinopraxis
#include <SPI.h>
#include <Ethernet.h>
// Ethernet
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAD };
byte ip[] = { 10, 0, 1, 101 };
byte gateway[] = { 10, 0, 1, 1 };
byte subnet[] = { 255, 255, 255, 0 };
// initialize the library instance:
EthernetClient client;
const unsigned long requestInterval = 60000; // delay between requests
//char serverName[] = "http://www.worldweatheronline.com/feed/tz.ashx"; // time URL
// Server
IPAddress server(81,201,134,251);
boolean requested; // whether you've made a request since connecting
unsigned long lastAttemptTime = 0; // last time you connected to the server, in milliseconds
String currentLine = ""; // string to hold the text from server
String time = ""; // string to hold the time
boolean readingTime = false; // if you're currently reading the time
void setup() {
// reserve space for the strings:
currentLine.reserve(256);
time.reserve(150);
// Start Serial Port
Serial.begin(9600);
Serial.println("Setup...");
// Start Ethernet
Ethernet.begin(mac, ip);
// connect to Time Server:
connectToServer();
}
void loop()
{
if (client.connected()) {
if (client.available()) {
// read incoming bytes:
char inChar = client.read();
// add incoming byte to end of line:
currentLine += inChar;
// if you get a newline, clear the line:
if (inChar == '\n') {
currentLine = "";
}
// if the current line ends with <localtime>, it will
// be followed by the time:
if ( currentLine.endsWith("<localtime>")) {
// time is beginning. Clear the time string:
readingTime= true;
time = "";
}
// if you're currently reading the bytes of the time,
// add them to the time String:
if (readingTime) {
if (inChar != '<') {
time += inChar;
}
else {
// if you got a "<" character,
// you've reached the end of the time:
readingTime = false;
Serial.println(time);
// close the connection to the server:
client.stop();
}
}
}
}
else if (millis() - lastAttemptTime > requestInterval) {
// if you're not connected, and two minutes have passed since
// your last connection, then attempt to connect again:
connectToServer();
}
}
void connectToServer() {
// attempt to connect, and wait a millisecond:
Serial.println("connecting to server...");
//if (client.connect(serverName, 80)) {
if (client.connect(server, 80)) {
Serial.println("making HTTP request...");
// make HTTP GET request to server:
client.println("GET /feed/tz.ashx?key=(yourkey_here)&q=london&format=xml");
client.println("HOST: www.worldweatheronline.com");
client.println();
}
// note the time of this connect attempt:
lastAttemptTime = millis();
}