I'm trying to read an XML file with PHP but I get this error and don't know what I've done wrong.
Warning: file_get_contents(username:password@http://ift.tt/1ICiPSz) [function.file-get-contents]: failed to open stream: No such file or directory in /www/htdocs/*******/mobile.php on line 11
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /www/htdocs/*******/mobile.php:12 Stack trace: #0 /www/htdocs/w00f6d79/mobile.php(12): SimpleXMLElement->__construct('') #1 {main} thrown in /www/htdocs/*******/mobile.php on line 12
My code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mobile.de</title>
</head>
<body>
<?php
$url = "username:password@http://ift.tt/1ICiPSz";
$xml = file_get_contents($url);
$data = new SimpleXMLElement($xml);
echo $data->children('ad', true)->ad->vehicle->class->children()->children('resource', true)->local-description;
?>
</body>
</html>
No comments:
Post a Comment