I am getting an XML document like this:
<?xml version="1.0" encoding="UTF-8"?>
@namespace html url(http://www.w3.org/1999/xhtml); :root { font:small Verdana; font-wei.... huge list of styling
<items>
<item>
...
That second line seems to be preventing me from parsing the file.
Using Tidy
<?php
$config = array(
'indent' => true,
'input-xml' => true,
'output-xml' => true,
'wrap' => false);
$tidy = new tidy;
$tidy->parseFile('https://website.com/path/to/XML.ashx?param=12345', $config);
$tidy->cleanRepair();
print_r($tidy);
?>
which will result in:
tidy Object
(
[errorBuffer] =>
[value] => <?xml version="1.0" encoding="utf-8"?>
)
Using simplexml_load_file()
<?php
$xml = simplexml_load_file('https://website.com/path/to/XML.ashx?param=12345');
print_r($xml);
?>
output:
**Warning**: simplexml_load_file(): https://website.com/path/to/XML.ashx?param=12345:1: parser error : Start tag expected, '<' not found in **C:\xampp\htdocs\local\php\script.php** on line 2
**Warning**: simplexml_load_file(): <?xml version="1.0" encoding="utf-8" ?> in **C:\xampp\htdocs\local\php\script.php** on line 2
**Warning**: simplexml_load_file(): ^ in **C:\xampp\htdocs\local\php\script.php** on line 2
I've also tried various cURL options and simply file_get_contents()
My question is: What is that second line of XML and how can I parse this file?