Salve, come da titolo non capisco perchè nell costruzione e/o modifica di file .xml la formattazione non viene presa in considerazione?
se io ho:
Codice PHP:
<?xml version="1.0" encoding="utf-8"?>
<gallery/>
se aggiungo un nodo:
Codice PHP:
<?xml version="1.0" encoding="utf-8"?>
<gallery>
    [img]img/nome.jpg[/img]
</gallery>
fin qui tutto ok, ma non appena aggiungo il secondo nodo:
Codice PHP:
<?xml version="1.0" encoding="utf-8"?>
<gallery>
    [img]img/nome.jpg[/img]
[img]img/nome.jpg[/img]</gallery>
e dal terzo in poi:
Codice PHP:
<?xml version="1.0" encoding="utf-8"?>
<gallery>
    [img]img/nome.jpg[/img]
[img]img/nome.jpg[/img][img]img/nome.jpg[/img]</gallery>
qualcuno sa come mai?
Qui il codice che crea il file ed aggiunge eventuali nodi:
Codice PHP:
//il "$this" dipende dal fatto che sta tutto in una classe
if(se non esiste il file.xml){
   
$this->gxml = new DOMDocument("1.0""utf-8");
   
$this->gxml->formatOutput true;
   
$this->gxml->appendChild($this->gxml->createElement("gallery") );
   
$this->root $this->gxml->documentElement;
   
$this->gxml->save($this->nome_dir.".xml");
}
else{
   
$this->gxml = new DOMDocument("1.0""utf-8");
   
$this->gxml->load($nome.".xml");
   
$this->gxml->formatOutput true;
   
$this->root $this->gxml->documentElement;
   
//sulla riga sopra anche $this->root = $this->gxml->firstChild;
}

//quando aggiungo un nodo
$this->root->appendChild($this->gxml->createElement("img") ); 
Grazie.