Visualizzazione dei risultati da 1 a 2 su 2

Discussione: problemino Flash e XML

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    165

    problemino Flash e XML

    Salve, stavo facendo delle prove con Flash. In particolare stavo tentando di leggere alcune informazioni da un file XML.
    Ho un file XML strutturato in questa maniera:
    Codice PHP:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
        <zona xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">     
             <tipoalloggio>         
                         <comune>Abc</comune>         
                         <nome>Nido dei merli</nome>         
                         <indirizzo>Via Maritano, 1</indirizzo>         
                         <tel>555 5555555</tel>         
                         <fax>444 4444444</fax>         
                         <email>info@nidodeimerli.it</email>
                  <web>[url]www.nid.it[/url]</web>         
                         <camere>6</camere>         
                         <servizi>parcheggio</servizi>     
              </tipoalloggio>
    .....
     </zona>
    Ho creato un piccolo action script collegato ad un piccolo form (che per ora non serve a nulla):

    Codice PHP:
    var xmlLoader:URLLoader = new URLLoader();
    var 
    xmlData:XML = new XML();

    contact_name.text contact_email.text "";

    send_button.addEventListener(MouseEvent.CLICKsubmit);
    reset_button.addEventListener(MouseEvent.CLICKreset);

    var 
    timer:Timer;
    var 
    var_load:URLLoader = new URLLoader;

    function 
    submit(e:MouseEvent):void
    {
        if( 
    contact_name.text == "" || contact_email.text == "")
        {
            
    message_status.text "Please fill up all text fields.";
        }
        else
        {
            
    xmlLoader.addEventListener(Event.COMPLETELoadXML);
            
    xmlLoader.load(new URLRequest("affittacamere_penisolasorrentina_capri.xml"));

        }
    }

    function 
    reset(e:MouseEvent):void
    {
        
    contact_name.text contact_email.text contact_subject.text 
        
    contact_message.text message_status.text "";
    }


    function 
    receive_response(e:Event):void
    {
        var 
    loader:URLLoader URLLoader(e.target);
        var 
    email_status = new URLVariables(loader.data).success;
        
        if( 
    email_status == "yes" )
        {
            
    message_status.text "Success! Your message was sent.";
            
    timer = new Timer(500);
            
    timer.addEventListener(TimerEvent.TIMERon_timer);
            
    timer.start();
        }
        else
        {
            
    message_status.text "Failed! Your message cannot sent.";
        }
    }

    function 
    on_timer(te:TimerEvent):void 
    {
        if( 
    timer.currentCount >= 10 )
        {
            
    contact_name.text contact_email.text contact_subject.text 
            
    contact_message.text message_status.text "";
            
    timer.removeEventListener(TimerEvent.TIMERon_timer);
        }
    }

    function 
    LoadXML(e:Event):void  {
      
    xmlData = new XML(e.target.data);
       
    ParseStructure(xmlData);
    }

    function 
    ParseStructure(structureInput:XML):void  {
      
    trace("XML Output");
      
    trace("------------------------");

      var 
    structureList:XMLList structureInput.tipoalloggio.(comune == "abc");
      
    trace(structureList);

    l'errore in output è il seguente:

    Codice PHP:
    XML Output ------------------------ 
    ReferenceErrorError #1065: La variabile comune non è definita.     
    at prova2_fla::contactform_1/ParseStructure()     at prova2_fla::contactform_1/LoadXML()     
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()     
    at flash.events::EventDispatcher/dispatchEvent()     at flash.net::URLLoader/flash.net:URLLoader::onComplete() 
    dov'è l'erreore???
    se provo a scrivere:
    var structureList:XMLList = structureInput.tipoalloggio.comune;
    mi mostra solo tutti i comuni presenti all'interno del file XML. Ho trovato sulla rete l'esempio che vedete nel listato per dare in output solo i comuni in cui c'è scritto "abc". Ma non va! L'errore lo da una volta premuto il tasto send. Come devo fare???

    Un'altra cosa che non riesco a fare è mettere al posto di "abc" il valore ottenuto dal form, mi date qualche dritta??

    Grazie!

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2009
    Messaggi
    165
    Risolto!! Almeno in parte.

    Codice PHP:
    ..................
    function 
    ParseStructure(structureInput:XML):void  {   
    trace("XML Output");   
    trace("------------------------");    
    var 
    structureList:XMLList structureInput.tipoalloggio;      
    trace(structureList.(elements('comune') == contact_name.text)); }//contact_name è il valore  
                                                                                              //inserito da form 
    ora effettivamente mi da in output solo i dati desiderati, ma la domanda ora è un'altra:
    come faccio a prendere i dati (nome,indirizzo,tel,fax..) e metterli in una variabile per poi farli stampare come in una tabella?

    Grazie

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 © 2024 vBulletin Solutions, Inc. All rights reserved.