genten
Bekanntes Mitglied
- Dabei seit
- 26.09.2007
- Beiträge
- 135
- Reaktionspunkte
- 0
Hi Leute!
Ich brauch mal wieder eure Hilfe: Ich bekomme immer die Fehlermeldungen
bei diesem PHP-Code:
Mit XML kenne ich mich leider nicht so aus. Kann mir vielleicht jemand helfen?
Gruß
genten
Ich brauch mal wieder eure Hilfe: Ich bekomme immer die Fehlermeldungen
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in ***\***\wetter.php on line 25
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: 582 in ***\***wetter.php on line 25
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in ***\***\wetter.php on line 25
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in ***\***\wetter.php:25 Stack trace: #0 ***\***\wetter.php(25): SimpleXMLElement->__construct('582??<?xml vers...') #1 {main} thrown in C:\XAMPP\xampplite\htdocs\Startpage\wetter.php on line 25
bei diesem PHP-Code:
PHP:
<?php
ort = "Hamburg";
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
$out = "GET /ig/api?weather=".$ort."&hl=de HTTP/1.1\r\n";
$out .= "Host: www.google.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp))
{
$xml.=fgets($fp, 128);
}
fclose($fp);
$xml=split("\r\n\r\n",$xml);
$xml = new SimpleXMLElement($xml[1]);
$weather = simplexml_load_string(utf8_encode($xml[1]));
$weather = $weather->weather;
echo $weather->current_conditions->condition["data"];
}
?>
Gruß
genten