Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558

    DOM e XML: funzione setAttribute

    Provo a settare un attributo ad un elemento che ottengo con

    Codice PHP:
    $doc DOMDocument::load(PHOTO_GALLERY_DIR.$folder.'/gallery.xml');
    $doc->validateOnParse true;
    // Take a root element
    $root_element $doc->getElementById('gallery');
    // Set attribute
    $root_element->setAttribute('title'$name); 
    Però ottengo questo errore:
    Fatal error: Call to a member function setAttribute() on a non-object in /home/gabriele/public_html/mio_sito.it/admin/model/photo-gallery/album.inc on line 93,
    dove la linea 93 è

    Codice PHP:
    // Set attribute
    $root_element->setAttribute('title'$name); 
    Qualche idea o suggerimento?

  2. #2
    Codice PHP:
    $doc->validateOnParse true
    questo dove l'hai trovato


    fai un var_dump($root_element) ad occhio e croce
    è nullo


    ma nel file xml esiste un nodo così
    strutturato (item per un esempio)
    <item id='gallery'>qualcosa</item>


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558
    Allora...
    Codice PHP:
    $doc->validateOnParse true
    l'ho presto da qui
    e nel file esiste un file con
    <item id='gallery'>
    <another_item></another_item>
    <another_item></another_item>
    <another_item></another_item>
    <another_item></another_item>
    </item>
    ...ora provo a fare il controllo che mi hai detto...grazie mille...

  4. #4
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558
    Cavolo, in effetti è nullo...ma come è possibile? Ora provo con getElementsByName

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.