Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Generare file xml con php

Generare file xml con php

Pianificato Fissato Bloccato Spostato Coding
5 Post 3 Autori 3.1k Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • A
    A
    ale90
    scritto su ultima modifica di
    User Attivo 5
    #1
    Generare file xml con php

    Ciao ragazzi, stò facendo un codice per generare un file xml in modo da interfacciarlo con un gestionale, il codice è questo solo che non funziona .(

    <?php 
    include("../../inc/config.php"); 
    $limite = "10";
    
    header("Content-type: text/xml; charset=utf-8");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    echo "<Company>";
    echo "<Name>Nome azienda</Name>";
    echo "<Address>Indirizzo azienda</Address>";
    echo "<Postcode>cap</Postcode>";
    echo " <City>citta</City>";
    echo "<Province>provincia</Province>";
    echo "<Country>Italia</Country>";
    echo "<FiscalCode>partita iva</FiscalCode>";
    echo "<VatCode>partita iva</VatCode>";
    echo "<Tel>tel</Tel>";
    echo "<Fax>fax</Fax>";
    echo "<Email>mail</Email>";
    echo "<HomePage>sito</HomePage>";
    echo "</Company>";
    echo " <Documents>";
    
    
    $query = @mysql_query("SELECT * FROM preventivi_clienti ORDER BY id DESC LIMIT 0," . $limite . "");
    while($result = @mysql_fetch_array($query)) 
    { 
    $nome_db = $result['nome'];
    $nome_db = mb_convert_encoding(htmlspecialchars($nome_db , ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $cognome_db =  $result['cognome'];
    $cognome_db= mb_convert_encoding(htmlspecialchars($cognome_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $indirizzo_db = $result['indirizzo'];
    $indirizzo_db = mb_convert_encoding(htmlspecialchars($indirizzo_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $cap_db = $result['cap'];
    $cap_db = mb_convert_encoding(htmlspecialchars($cap_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $citta_db = $result['citta'];
    $citta_db = mb_convert_encoding(htmlspecialchars($citta_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $stato_db = $result['stato'];
    $stato_db = mb_convert_encoding(htmlspecialchars($stato_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $telefono_db = $result['telefono'];
    $telefono_db = mb_convert_encoding(htmlspecialchars($telefono_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $email_db = $result['email'];
    $email_db = mb_convert_encoding(htmlspecialchars($email_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $data_db = $result['data'];
    $data_db = mb_convert_encoding(htmlspecialchars($data_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    
    $note_db = $result['note'];
    $note_db = mb_convert_encoding(htmlspecialchars($note_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
    ?>
     <Document>
          <DocumentType>C</DocumentType>
          <CustomerCode><?php echo $result[id]; ?></CustomerCode>
          <CustomerName><?php echo "$nome_db $cognome_db"; ?></CustomerName>
          <CustomerAddress><?php echo "$indirizzo_db"; ?></CustomerAddress>
          <CustomerPostcode><?php echo "$cap_db"; ?></CustomerPostcode>
          <CustomerCity><?php echo "$citta_db"; ?></CustomerCity>
          <CustomerProvince></CustomerProvince>
          <CustomerCountry><?php echo "$stato_db"; ?></CustomerCountry>
          <CustomerTel><?php echo "$telefono_db"; ?></CustomerTel>
          <CustomerEmail><?php echo "$email_db"; ?></CustomerEmail>
          <Date><?php echo "$data_db"; ?></Date>
          <Number></Number>
          <Total></Total>
          <PaymentName>Bonifico bancario</PaymentName>
          <PaymentBank>BANCA: UNICREDITBANCA AG. 884 GARIBALDI TRIESTE Codice IBAN: IT 83 Y 02008 02204 0000 15662502</PaymentBank>
           <CustomField1><?php echo "$note_db"; ?></CustomField1>
          <InternalComment>Nessun Acconto</InternalComment>
           <Row>
            <Code>0043</Code>
            <Description>Appendiabiti su ruote. In robusto metallo verniciato dotato di griglia portascarpe in filo metallico.</Description>
            <Qty>1</Qty>
            <Um>pz</Um>
            <Price>162</Price>
            <Discounts>5%</Discounts>
            <VatCode>20</VatCode>
          </Row>
          <Row>
            <Code>0039</Code>
            <Description>Cestini Gettacarta - Pareti in acciaio laminato nero o acciaio</Description>
            <Qty>3</Qty>
            <Um>pz</Um>
            <Price>16</Price>
            <Discounts>5%</Discounts>
            <VatCode>20</VatCode>
          </Row>
    
        </Document>
    
    <?
    } 
    ?>
    
      </Documents>
    </EasyfattDocuments>
    

    Mi da questo errore

    This page contains the following errors:

    error on line 1 at column 405: Extra content at the end of the document
    Below is a rendering of the page up to the first error.

    Io in pratica dovrei generare un file xml con questa struttura solo nn capisco xke nn funziona 😞

    Ciau

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • L
      L
      linoma
      scritto su ultima modifica di
      User Attivo 14
      #2

      Nn ti puo' aiutare le libreria XMLWriter?

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • L
        L
        linoma
        scritto su ultima modifica di
        User Attivo 14
        #3

        developphp.com/tutorial_read.php?tid=72

        Nn rieesco a modificare il post precedente

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0
        • A
          A
          ayrton2001
          scritto su ultima modifica di
          Super User 20
          #4

          Come primo problema veco che manca il tag di apertura di </EasyfattDocuments>

          1 Risposta Ultima Risposta
          Miglior risposta 0
          0
          • A
            A
            ale90
            scritto su ultima modifica di
            User Attivo 5
            #5

            Adesso sn riuscito a generare il file

            $query = mysql_query("
            SELECT * 
            FROM preventivi_clienti
            INNER JOIN preventivi_prodotti
            ON preventivi_clienti.preventivi_clienti_ses = preventivi_prodotti.ses
            INNER JOIN shop_prodotti
            ON shop_prodotti.id =  preventivi_prodotti.id_prodotto
            ");
            
            while($result = mysql_fetch_array($query)) 
            { 
            $id_db =  $result['preventivi_clienti_id'];
            $id_db= mb_convert_encoding(htmlspecialchars($id_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $nome_db = $result['preventivi_clienti_nome'];
            $nome_db = mb_convert_encoding(htmlspecialchars($nome_db , ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $cognome_db =  $result['preventivi_clienti_cognome'];
            $cognome_db= mb_convert_encoding(htmlspecialchars($cognome_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $indirizzo_db = $result['preventivi_clienti_indirizzo'];
            $indirizzo_db = mb_convert_encoding(htmlspecialchars($indirizzo_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $cap_db = $result['preventivi_clienti_cap'];
            $cap_db = mb_convert_encoding(htmlspecialchars($cap_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $citta_db = $result['preventivi_clienti_citta'];
            $citta_db = mb_convert_encoding(htmlspecialchars($citta_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $stato_db = $result['preventivi_clienti_stato'];
            $stato_db = mb_convert_encoding(htmlspecialchars($stato_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $telefono_db = $result['preventivi_clienti_telefono'];
            $telefono_db = mb_convert_encoding(htmlspecialchars($telefono_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $email_db = $result['preventivi_clienti_email'];
            $email_db = mb_convert_encoding(htmlspecialchars($email_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $data_db = $result['preventivi_clienti_data'];
            $data_db = mb_convert_encoding(htmlspecialchars($data_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $note_db = $result['preventivi_clienti_note'];
            $note_db = mb_convert_encoding(htmlspecialchars($note_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $id_prodotto_db = $result['id_prodotto'];
            $id_prodotto_db = mb_convert_encoding(htmlspecialchars($id_prodotto_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $qnt_prod_db = $result['qnt'];
            $qnt_prod_db = mb_convert_encoding(htmlspecialchars($qnt_prod_db, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            
            $nome_prodotto = $result['nome'];
            $nome_prodotto = mb_convert_encoding(htmlspecialchars($nome_prodotto, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $art_prodotto = $result['articolo'];
            $art_prodotto= mb_convert_encoding(htmlspecialchars($art_prodotto, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            $unita_prodotto = $result['unita'];
            $unita_prodotto= mb_convert_encoding(htmlspecialchars($unita_prodotto, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            
            $prezzo_prodotto = $result['prezzo'];
            $prezzo_prodotto= mb_convert_encoding(htmlspecialchars($prezzo_prodotto, ENT_NOQUOTES, 'Windows-1252'), 'UTF-8', 'Windows-1252');
            
            echo "
                <Document>
                  <DocumentType>C</DocumentType>
                  <CustomerCode>$id_db</CustomerCode>
                  <CustomerName>$nome_db $cognome_db</CustomerName>
                  <CustomerAddress>$indirizzo_db</CustomerAddress>
                  <CustomerPostcode>$cap_db</CustomerPostcode>
                  <CustomerCity>$citta_db </CustomerCity>
                  <CustomerProvince></CustomerProvince>
                  <CustomerCountry>$stato_db </CustomerCountry>
                  <CustomerVatCode></CustomerVatCode>
                  <CustomerTel>$telefono_db</CustomerTel>
                  <CustomerEmail>$email_db</CustomerEmail>
                  <Date>$data_db</Date>
                  <Number></Number>
                  <Total></Total>
                   <InternalComment>Nessun Acconto</InternalComment>
                  <CustomField1>$note_db</CustomField1>
                  <Row>
                    <Code>$art_prodotto</Code>
                    <Description>$nome_prodotto</Description>
                    <Qty>$qnt_prod_db</Qty>
                    <Um>pz</Um>
                    <Price>$prezzo_prodotto</Price>
                    <Discounts>5%</Discounts>
                    <VatCode>20</VatCode>
                  </Row>
            
                </Document>";
            }
            

            Il codice funziona, solo che non fà quello che voglio io, adesso vi spiego.

            Il codice mi da questo risultato

            cliente1
            prodotto1

            cliente1
            prodotto2

            cliente1
            prodotto3

            Io invece vorrei una cosa del genere

            cliente1
            prodotto1
            prodotto2
            prodotto3

            Il problema penso sia il while..

            Mi sapete dare un consiglio su come fare?

            Ciau

            1 Risposta Ultima Risposta
            Miglior risposta 0
            0

            Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

            Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

            Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

            Registrati Accedi
            Rispondi
            • Risposta alla discussione
            Effettua l'accesso per rispondere
            • Da Vecchi a Nuovi
            • Da Nuovi a Vecchi
            • Più Voti


            • Accedi

            • Non hai un account? Registrati

            • Accedi o registrati per effettuare la ricerca.
            • Primo post
              Ultimo post
            Home Accedi Registrati
            Menu
            • CATEGORIES
            • La Community Connect.gt
            • Presentati alla Community
            • News Ufficiali da Connect.gt
            • Internet News
            • A Scuola Di
            • Digital Marketing
            • Intelligenza Artificiale
            • SEO & GEO
            • Web Marketing e Content
            • Google Analytics e Web Analytics
            • Google Ads & Advertising
            • YouTube
            • TikTok, Instagram e altri Social
            • Google Adsense, Affiliazioni e Guadagno
            • E-Commerce
            • Coding e Sistemistica
            • Help Center: consigli per il tuo progetto
            • Hosting e Cloud
            • Coding
            • CMS & Piattaforme Self-Hosted
            • Annunci e Collaborazioni
            • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
            • Collaborazioni WEB e Lavoro: offro e cerco
            • Impresa, Fisco e Leggi
            • Consulenza Legale e Professioni Web
            • Consulenza Fiscale, Imprese, Startup e P.Iva
            • Gli Off Topic
            • PC, Smartphone e altri Hardware
            • Tutti i Software
            • GT Fetish Cafè
            • Discussioni
            • Non letti 0
            • Recenti
            • Hashtag
            • Popolare
            • Utenti
            • Privacy
            • Termini e condizioni
            • © 2026 Search On Media Group S.r.l.