Re: [Rusty] Passing PHP Variables from CMS Builder to XML
Made some headway...
Based off of the premise that the headers will be sent by ANYTHING that comes after the doctype, I switched it around to declare the doctype AFTER I call the data from the table:
So now the beginning of my XML file looks like this:
<?php
require_once "/public_html/admin/lib/viewer_functions.php";
list($f00Records, $f00MetaData) = getRecords(array(
'tableName' => 'f00',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$f00rRecord = @f00Records[0]; // get first record
// show error message if no matching record is found
if (!$f00rRecord) {
header("HTTP/1.0 404 Not Found");
print "f00 Record not found!";
exit;
}
?><?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
But I am also getting another error that I believe resolves from trying to use the plaintext
& instead of the html number.
More or less, the commonly used
& (ampersand) is one of a handful of special characters which cause an XML string to error out when it tries to parse the data. Others that it happens to screw up/error out with are
(#, <, >, &).
I'm currently going to try wrapping this around my plaintext. I was trying to list plaintext like "Item A & Item B" and it is erroring out on the
&.
This is what I wrapped around my PHP vars.
<!-- info 1-->
<title><![CDATA[<?php echo $f00Record['title'] ?>]]></title>
<description><![CDATA[<?php echo $f00Record['description'] ?>]]></description>
Rusty