$new_root_node = $val->replace_node($new_node);
    } else {
        $last = $p->next_sibling();
        $prev = $p->previous_sibling();
        $father = $p->parent_node();
        for ($i = 0; $i < count($dati); $i++) {
            $tmp_root[$i] = $dom->create_element("text:p");
            $tmp_root[$i]->set_attribute("text:style-name", $p_value);
            $tmp = $dom->create_text_node(utf8_encode(html_entity_decode($dati[$i])));
            $tmp_root[$i]->append_child($tmp);
            if (!$last) {
                $father->append_child($tmp_root[$i]);
            } else {
                $father->insert_before($tmp_root[$i], $last);
            }
        }
        $p->unlink_node();
        $val->unlink_node();
    }
}
// Scrivo il file
$dom->dump_file(getcwd() . "/{$dir}/content.xml", false, true);
//visita_XML($root,0);
//Comprimo il file
$zipfile = new zipfile();
$zipfile->add_sub_dir("./" . $dir, "./" . $dir);
$zipfile->list_file("./" . $dir, "./" . $dir);
$fd = fopen($dir_save . "/" . $nomefile, "wb");
$out = fwrite($fd, $zipfile->file());
fclose($fd);
rmdirr($dir);