protected function implodeNode($node) { $attributes = array(); foreach ($node->attributes() as $k => $v) { $attributes[] = $k . '="' . (string) $v . '"'; } return '<' . $node->getName() . ' ' . implode(' ', $attributes) . '>'; }