Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $stmt = $conn->query('SELECT user_name, user_email, user_pass FROM users');
- $stmt->setFetchMode(PDO::FETCH_ASSOC);
- $document = new DOMDocument('1.0', 'UTF-8');
- $annunci = $document->createElement('annunci'); // 1. Nodo Annunci
- foreach ($stmt as $row) {
- $annuncio = $document->createElement('annuncio'); // 2. Ciclo Nodo Annuncio
- // $entry->setAttribute('submissionDate', $row['date_entered']);
- $annuncio->appendChild($document->createElement('id_annuncio_immobile', $row['user_name']));
- $annuncio->appendChild($document->createElement('idtipologiaimmobile', $row['user_email']));
- // and so on
- // CDATA sections are slightly different
- $description = $document->createElement('descrizione');
- $description->appendChild($document->createCDATASection($row['user_pass']));
- $annuncio->appendChild($description);
- // Inizio Sub Ciclo
- $stmt2 = $conn->query('SELECT nome_file FROM foto_news');
- $stmt2->setFetchMode(PDO::FETCH_ASSOC);
- //
- // $immagini = $document->createElement('immagini'); // 2. Ciclo Nodo Annuncio
- // $annuncio->appendChild($immagini);
- $b = $document->createElement( "immagini" );
- foreach ($stmt2 as $row) {
- /*
- $annuncio1 = $document->createElement('annuncio1'); // 2. Ciclo Nodo Annuncio
- $annuncio1->appendChild($document->createElement('id_annuncio_immobile', $row['nome_file']));
- $annunci->appendChild($annuncio1); // 2. Ciclo Nodo Annuncio
- */
- $immagine = $document->createElement('immagine');
- $immagine->appendChild($document->createElement('link', $row['nome_file']));
- $annuncio->appendChild($immagine);
- // $annuncio->appendChild($immagini);
- }
- $annuncio->appendChild($b);
- // Fine Sub Ciclo
- $annunci->appendChild($annuncio); // 2. Ciclo Nodo Annuncio
- }
- $document->appendChild($annunci); // 1. Nodo Annunci
- // Set the appropriate content-type header and output the XML
- header('Content-type: application/xml');
- echo $document->saveXML();
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement