How do i echo the contents of a variable in XML?



I have a bit of troube making my php code. I have a PHP code that generates some content that I need to have inside of an XML.


This is a snippet of what it looks like:



<?php
date_default_timezone_set('America/New_York');
$date=date('o-m-d');
$time=date('G:i:s');
...
...


And I need to have it inside an xml, what I tried was golfing the code into one line.



date_default_timezone_set('America/New_York'); $date=date('o-m-d'); $time=date('G:i:s');


Then setting it as variable, in this case called $strDateTime. Then i tried this:



//
echo("<strDateTime>". $strDateTime ."</strDateTime>");


But it didn't work, and it gave me an XML error, which said that the document was emtpy? The content that the file generates is 100% compapitable with XML. I tried generating it and then putting the generated content there and worked perfeclty fine. The problem is that the contents changes every second.


No comments:

Post a Comment