In my XML-code I want to make a link to popup an image.
I have this code:
the data comes from this array:
$files[] = array(
"filename"=>$file,
"intLatitude"=>$intLatitude,
"intLongitude"=>$intLongitude);
"directory"=>$$dh;
------------------
-and the XML-file:
$picfil = $dir."/".$name;
$file = fopen($dir."/".$name,"w");
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<gpx>';
$xml .= '<metadata>';
$xml .= '<extensions>';
$xml .= '</extensions>';
$xml .= '</metadata>';
for($i = 0; $i < sizeof($files); ++$i) {
$xml .= '<wpt lat="' . $files[$i]['intLatitude'] .'" lon="' . $files[$i]['intLongitude'] .'">';
$xml .= '<extensions>';
$xml .= '<html>';
$xml .= '<![CDATA[<a href="#"><img src="'.parseToXML($files[$i]['filename']) .'"/></a>]]>';
$xml .= '</html>';
$xml .= '</extensions>';
$xml .= '</wpt>';
}
$xml .= '</gpx>';
fwrite($file,$xml);
fclose($file);
-and the function parseToXML
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
I want to change the CDATA-code so I can open the image in an popup-window. The images is in different directories, so the must be a variable.
I have this code:
the data comes from this array:
$files[] = array(
"filename"=>$file,
"intLatitude"=>$intLatitude,
"intLongitude"=>$intLongitude);
"directory"=>$$dh;
------------------
-and the XML-file:
$picfil = $dir."/".$name;
$file = fopen($dir."/".$name,"w");
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<gpx>';
$xml .= '<metadata>';
$xml .= '<extensions>';
$xml .= '</extensions>';
$xml .= '</metadata>';
for($i = 0; $i < sizeof($files); ++$i) {
$xml .= '<wpt lat="' . $files[$i]['intLatitude'] .'" lon="' . $files[$i]['intLongitude'] .'">';
$xml .= '<extensions>';
$xml .= '<html>';
$xml .= '<![CDATA[<a href="#"><img src="'.parseToXML($files[$i]['filename']) .'"/></a>]]>';
$xml .= '</html>';
$xml .= '</extensions>';
$xml .= '</wpt>';
}
$xml .= '</gpx>';
fwrite($file,$xml);
fclose($file);
-and the function parseToXML
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
I want to change the CDATA-code so I can open the image in an popup-window. The images is in different directories, so the must be a variable.