Home » Php » php – Simple XML namespace warning

php – Simple XML namespace warning

Posted by: admin July 12, 2020 Leave a comment

Questions:

I am trying to parse the following XML using simplexml…

http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/xml/500?key=ed47ad61-5033-48c8-bf7c-6c4c0b17c3f3

but as soon as I add the line…

$xml = simplexml_load_file('http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/xml/500?key=ed47ad61-5033-48c8-bf7c-6c4c0b17c3f3');

I get and error like

namespace warning : xmlns: URI www.metoffice.gov.uk/xml/metoRegionalFcst is not absolute

I can’t seem to work out how to get around this problem.

How to&Answers:

just add @ before simplexml_load_file

like

$xml = @simplexml_load_file(‘http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/xml/500?key=ed47ad61-5033-48c8-bf7c-6c4c0b17c3f3‘);

Answer:

libxml_use_internal_errors(true);
$xml = simplexml_load_file($file->getTempName());


us3.php.net/manual/es/function.simplexml-load-file.php
us3.php.net/manual/es/function.libxml-use-internal-errors.php
us3.php.net/manual/es/simplexml.examples-errors.php