Hi,
I am having issues using simplexml. I have generated an XML file using PHP (link), and I am trying to load it into a simplexml object using:
This is generating a parser error:
It looks as if it's trying to parse the actual PHP script, and not the generated XML. I have set the MIME type on the PHP file to text/xml. Here is the script that generates the XML:
I am pretty new to XML, is this even possible? If not, what other methods are available to me?
I am having issues using simplexml. I have generated an XML file using PHP (link), and I am trying to load it into a simplexml object using:
Code:
$xml = simplexml_load_file("news_headlines_xml.php");
Warning: simplexml_load_ file() [function.simple xml-load-file]: news_headlines_ xml.php:72: parser error : Start tag expected, '<' not found in /home/airfront/public_html/FedEx4/functions.php on line 5
Warning: simplexml_load_ file() [function.simple xml-load-file]: $xmlString = '<?xml version="1.0" encoding="utf-8"?>'; in /home/airfront/public_html/FedEx4/functions.php on line 5
Warning: simplexml_load_ file() [function.simple xml-load-file]: $xmlString = '<?xml version="1.0" encoding="utf-8"?>'; in /home/airfront/public_html/FedEx4/functions.php on line 5
Code:
// Begin XML
$xmlString = '<?xml version="1.0" encoding="utf-8"?>';
$xmlString .= "<NEWS>";
// Begin data output
if($getPostCount<count($posts)){
for($b=0;$b<$getPostCount;$b++){
$xmlString .= "<ARTICLE>";
$xmlString .= "<AUTHOR>" . $postArray[$posts[$b]]['poster_name'] . "</AUTHOR>";
$xmlString .= "<SUBJECT>" . str_replace("\"", """, $postArray[$posts[$b]]['post_subject']) . "</SUBJECT>";
$xmlString .= "<TIME>" . $postArray[$posts[$b]]['post_time'] . "</TIME>";
$xmlString .= "</ARTICLE>";
}
}
$xmlString .= "</NEWS>";
echo $xmlString;
Comment