insert URL stored in jpeg metadata into dynamic xml - url gets truncated

Hi,
when I try to insert the text stored as $comments into the dynamically created xml the text is truncated to the first letter. do I have to convert what is stored in $comments first ??
Why does the ‘echo’ work but the ‘createElement’ does not ?
Heres the code
[php]<?php
/* create a dom document with encoding utf8, creates the initial xml element and also tidies things */
$domtree = new DOMDocument(‘1.0’, ‘UTF-8’);
$domtree -> preserveWhiteSpace = false;
$domtree -> formatOutput = true;

/* other data */
$other = $domtree->createElement(“other”);
$other = $domtree->appendChild($other);

/* THE FILES */
$directory = ‘cycle_images/’;
try {
foreach ( new DirectoryIterator($directory) as $item ) {
if ($item->isFile()) {
$path = $directory . $item;

			$exif = exif_read_data($path, 0, true);
			$comments = $exif['IFD0']['Comments'];

			/* THE FOLLOWING LINE TRUNCATES THE COMMENT TO THE FIRST LETTER */
			$other->appendChild($domtree->createElement('comments',"$comments"));

			/* THE FOLLOWING LINE PRINTS THE WHOLE COMMENT PROPERLY */
			echo $comments===false ? "No Comment data found.<br />\n" : "$comments<br />\n";
			
        }
    }
}
catch(Exception $e) {
    $slideShow->appendChild($domtree->createElement('photo','Top Frame items/John_Howland.gif'));
}

/* get the xml printed */
echo $domtree->saveXML();
?>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service