Search code examples
phpincludekmlcdata

PHP include statement within CDATA tag


I am generating a KML file (which is XML formatted for a Google Map) Within the infowindow section of the XML file is a CDATA tag. So when the infowindow is opened on the map, the data within can be formatted with HTML tags. Here is what I need to do. I need to have a PHP include statement within this cdata section. I am trying to place the following within the CDATA tag, <? include("http://www.yahoo.com"); ?> However what I see when the page loads is: <![CDATA[<div> &lt;? include(&quot;http://www.yahoo.com&quot;); ?&gt; &nbsp;</div> ]]> How can I get this corrected? Thanks,


Solution

  • If the file has a .kml extension, you'll need to tell your web server to use PHP to serve that file extension. Something like this would do it in Apache:

    AddType application/x-httpd-php .kml
    

    If it's a .php file, my suspicion is that PHP's sort tags are disabled, and that you need to use <?php instead of <?. There's nothing really special about a CDATA tag that'd break PHP.