getElementsByTagName('canvas')->item(0); for($i = 0; $i < $canvas->childNodes->length; $i++) { $child = $canvas->childNodes->item($i); if($child->tagName == 'param') { $pName = strtoupper($child->getAttribute('name')); $pValue = $child->getAttribute('value'); $replaceKeys[$pName] = $pValue; } } foreach($replaceKeys as $key=>$value) { $htmlTemplate = str_replace('['.$key.']', $value, $htmlTemplate); } $output = fopen($htmlOutput, "w"); fprintf($output, "%s", $htmlTemplate); fclose($output); } ?>