Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di wino_7
    Registrato dal
    Dec 2006
    Messaggi
    537

    Generare un file xml con php

    Salve ragazzi vorrei sapere se con php è possibile generare file .xml (da salvare sul server) in cui scriverci dentro, e poterlo far scaricare agli utenti.

  2. #2
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558
    Puoi cominciare da qui...poi qualsiasi cosa siamo qui...

    Codice PHP:
    <?php 

     
    //Creates XML string and XML document using the DOM 
     
    $dom = new DomDocument('1.0'); 

     
    //add root - <books> 
     
    $books $dom->appendChild($dom->createElement('books')); 

     
    //add <book> element to <books> 
     
    $book $books->appendChild($dom->createElement('book')); 

     
    //add <title> element to <book> 
     
    $title $book->appendChild($dom->createElement('title')); 

     
    //add <title> text node element to <title> 
     
    $title->appendChild
                     
    $dom->createTextNode('Great American Novel')); 

     
    //generate xml 
     
    $dom->formatOutput true// set the formatOutput attribute of 
                                // domDocument to true 
     // save XML as string or file 
     
    $test1 $dom->saveXML(); // put string in test1 
     
    $dom->save('test1.xml'); // save as file 
     
    ?>
    PS Se sei su win non hai problemi...se sei su *Unix non funziona se non hai le libxml!!!!!! Occhio...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.