XML + HTTP Get

Hallo,
Ich lese die XML-Datei einer Steuerung aus, damit ich aktuelle Daten bekomme muss ich dieses:

GET http://192.168.6.161/data/cyclic.xml?_=1380178018476 HTTP/1.1
Accept: /
Host: 192.168.6.161
Connection: Keep-Alive

vor:
$url= ‚http://192.168.6.161/data/static.xml‘;
$xml = simplexml_load_file($url);

dem eigentlichen Aufruf senden, wichtig ist das Flag Connection: Keep-Alive, wie kann ich das realisieren?

Sabl

Das habe ich gemacht:
$header = „Connection: keep-alive“;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, „http://192.168.6.161/data/static.xml“);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //$user_agent would contain your agent.
$xml = curl_exec($ch); //xml stored in the variable $xml
$xmldata = new SimpleXMLElement($xml);

Ich habe nun kein XML mehr und versuche das wieder in XML zu bringen mit: SimpleXMLElement, geht aber nicht, folgende Fehlermeldung:
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, ‚<‘ not found in C:\IP-Symcon\scripts\37370.ips.php on line 27

Warning: SimpleXMLElement::__construct(): 1 in C:\IP-Symcon\scripts\37370.ips.php on line 27

Warning: SimpleXMLElement::__construct(): ^ in C:\IP-Symcon\scripts\37370.ips.php on line 27

Fatal error: Uncaught exception ‚Exception‘ with message ‚String could not be parsed as XML‘ in C:\IP-Symcon\scripts\37370.ips.php:27
Stack trace:
#0 C:\IP-Symcon\scripts\37370.ips.php(27): SimpleXMLElement->__construct(‚1‘)
#1 {main}
thrown in C:\IP-Symcon\scripts\37370.ips.php on line 27

Und nun? Kann mir irgendwer helfen?

Sabl

Hallo,
Ich habe das Problem gelöst, Script poste ich morgen.

Sabl

so funktioniert es:
$header = „Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3“;
$header = „Content-Type: text/xml; charset=utf-8“;
$header = „Connection: keep-alive“;
$ch = curl_init(„http://192.168.6.161/data/static.xml“);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
//echo $output;
curl_close($ch);

$xml = simplexml_load_string(utf8_encode($output)) or die(„Unable to load XML file!“);

//var_dump($sims);
$ret = $xml->Device->HEATAREA[0]->HEATAREA_NAME;

Sabl

So funktioniert das senden:
$xml_builder = ’
<?xml version=„1.0“ encoding=„UTF-8“?>
<DEVICES>
<DEVICE>
<ID>Ezr</ID>
<HEATAREA nr=„0“>
<T_TARGET>’ . $IPS_VALUE . '</T_TARGET>
</HEATAREA>
</DEVICE>
</DEVICES>
';
$header = „Content-Length: 188“;
$header = „Connection: keep-alive“;
$header = „Content-Type: text/xml; charset=utf-8“;
$ch = curl_init(„http://192.168.6.161/data/changes.xml“);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ch_result = curl_exec($ch);
curl_close($ch);
echo $ch_result;

Sabl