1

I use DHTMLX's scheduler plugin. when i config the scheduler.load(). Does it support xml file only? i use php echo the same format data,but it's doesn't work. scheduler.load('1.xml') it's ok. but i use scheduler.load('1.php') it's doesn't work.

i don't generated xml file.i only use php echo:

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    echo "<data>";
    foreach($this->info as $value) {
        echo "<event id='".$value->reg->getStamp()."'>";
        echo "<start_date>".$value->reg->getDate()." ".$value->reg->getStartTime()."</start_date>";
        echo "<end_date>".$value->reg->getDate()." ".$value->reg->getEndTime()."</end_date>";
        echo "<text>".$value->reg->getTitle()."</text>";
        echo "<details>预约人:".$value->reg->sfGuardUser->getFirstName()."</details>";
        echo "</event>";
    }
    echo "</data>";

my php echo the data like this:

<?xml version="1.0" encoding="UTF-8"?><data><event id='1'><start_date>2011-12-16 05:00:00</start_date><end_date>2011-12-16 06:00:00</end_date><text>aaaa</text><details>register: lee</details></event></data>

my dhtmlx like this:

scheduler.load("/ajax/equRegInfo?equipmentid=874");
xiaobo
  • 53
  • 1
  • 1
  • 5
  • Impossible to answer without more details. Maybe the XML generated by your PHP is invalid (you cannot just paste XML into a .php file due to the ` – ThiefMaster Dec 29 '11 at 10:14

2 Answers2

1

There is no difference between outputting XML via a php script and using an XML file. This implies, that your XML file doesn't look exactly as you imagine. Here is what I would do:

Load your .php file in a browser, outside of the scheduler. Check out the XML. You should see the differences.

I also notice, you are using unicode characters. XML required [!CDATA[....]] construction for those.

KateYoak
  • 1,591
  • 3
  • 18
  • 34
1

It is very very important you tell PHP what to serve the data as. Change this line:

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

To this:

header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
// rest of script follows...

Make sure that you set the content-type before you echo anything out to the page.

dan
  • 856
  • 9
  • 20