2016-11-08 12 views
0

私は温度を測定する簡単なソフトウェアを行っています。 XMLを外部のブラウザやその他のソフトウェアに送信することは私にはできません。私がブラウザとArduinoに接続すると、私はこの写真を得る(下記)。何I'am間違っているの?:ArduinoイーサネットソケットでXMLを送信

enter image description here

XMLを送信するコードは次のとおりです。エラーが検出されました

EthernetClient client = server.available(); 
if (client) { 
Serial.println("new client"); 
// an http request ends with a blank line 
boolean currentLineIsBlank = true; 
while (client.connected()) { 
    if (client.available()) { 
    char c = client.read(); 
    Serial.write(c); 

    if (c == '\n' && currentLineIsBlank) { 
     client.println("HTTP/1.1 200 OK"); 
     client.println("Content-Type: text/xml;charset=UTF-8"); 
     client.println("Connection: close"); // the connection will be closed after completion of the response 
     client.println(); 
     client.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
     client.println("<TEMP>"); 

     client.print(calcTemp(cnt1), 3); 
     client.println("<TEMP/>"); 


     break; 
    } 
    if (c == '\n') { 
     // you're starting a new line 
     currentLineIsBlank = true; 
    } else if (c != '\r') { 
     // you've gotten a character on the current line 
     currentLineIsBlank = false; 
    } 
    } 
} 
// give the web browser time to receive the data 
delay(1); 
client.stop(); 

答えて

1

4行は以下の通りです:

client.println("<TEMP/>"); 

Xmlタグを閉じる正しい構文は次のとおりです。

client.println("</TEMP>"); 

注:構文<TEMP/>は、空の属性を宣言するために使用されます。これは<TEMP></TEMP>に相当します。

+0

Arrgg ..ありがとう:)私の間違い...それは今働いています.. – Ferguson

関連する問題