Visualizzazione dei risultati da 1 a 3 su 3

Discussione: problama con xml load

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2005
    Messaggi
    12

    problama con xml load

    io ho un xml con questa struttura:


    Code:

    <?xml version="1.0" encoding="UTF-8"?>
    <USCITE>
    <value id="Popotan 06">
    <crc>45AB1D9E</crc>
    <bytes>181.429.978</bytes>
    <giorno>27/04/2005</giorno>
    </value>
    <value id="Battle Athletess 01v2">
    <crc>6AA7A5A2</crc>
    <bytes>353.016.053</bytes>
    <giorno>22/04/2005</giorno>
    </value>



    ecc...

    ora con flash ho creato un nuovo documento ed ho un solo layer con un solo keyframe (per provare il codice)
    nel frame ho impostato questo codice:


    Code:

    filexml = "release.xml";

    ApriXML();
    function ApriXML () {
    mioxml = new XML();
    myarray = new Array();
    mioxml.load(filexml);
    mioxml.onLoad = ElaboraXML;
    function ElaboraXML (success) {
    if (mioxml.loaded) {
    myarray = mioxml.firstChild.nextSibling.childNodes;

    trace ("Tot elementi = " + myarray.length);

    for (i=0;i<=myarray.length;i++){

    if (myarray[i].nodeName == "value"){

    trace("------------------")

    trace(myarray[i].attributes.id)
    trace(myarray[i].childNodes[1].childNodes.toString())
    trace(myarray[i].childNodes[3].childNodes.toString())
    trace(myarray[i].childNodes[5].childNodes.toString())

    //trace("elemento ["+i+"] ------------------")
    //trace(myarray[i])
    }
    }
    }
    ;
    }
    ;
    }
    ;




    ora nella finestra output vedo correttamente la lettura del xml
    ma non ho capito a questo punto come portarla nel filmato principale, come visualizzare i valori nella pagina

    potreste aiutarmi?

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2005
    Messaggi
    12
    re

    allora io ho fatto una cosa del genere a logica (è la prima volta che uso xml+flash)


    Code:


    filexml = "release.xml";


    ApriXML();
    function ApriXML () {
    var mioxml = new XML();
    var myarray = new Array();
    mioxml.load(filexml);
    mioxml.onLoad = ElaboraXML;
    function ElaboraXML (success) {
    if (mioxml.loaded) {



    var myarray = mioxml.firstChild.nextSibling.childNodes;

    trace ("Tot elementi = " + myarray.length);

    for (var i=0;i<=myarray.length;i++){

    if (myarray[i].nodeName == "value"){

    trace("------------------")

    trace(myarray[i].attributes.id)
    trace(myarray[i].childNodes[1].childNodes.toString())
    trace(myarray[i].childNodes[3].childNodes.toString())
    trace(myarray[i].childNodes[5].childNodes.toString())
    //trace("elemento ["+i+"] ------------------")
    //trace(myarray[i])
    }
    var titolo = trace(myarray[i].childNodes[5].childNodes.toString());
    titolo.text += myarray[i].childNodes[5].childNodes.toString()
    }
    }
    ;
    }
    ;
    }
    ;





    solo che nel campo testo mi appare una cosa del genere

    defined22/04/2005undefined13/04/2005undefined15/04/2005undefined06/04/2005undefined22/03/2005undefined21/03/2005undefined11/03/2005undefined11/03/2005undefined03/03/2005undefined02/03/2005undefined02/03/2005undefined24/02/2005undefined18/02/2005undefined15/02/2005undefined11/02/2005undefined09/02/2005undefined01/02/2005undefined28/01/2005undefined25/01/2005undefined25/01/2005undefined2

    tutto su una sola linea
    anche se pare riuscire a leggere dal xml

    mentre nella finestrina output ora ho delle linee in più


    Code:


    Tot elementi = 361
    undefined
    ------------------
    Popotan 06
    45AB1D9E
    181.429.978
    27/04/2005
    27/04/2005
    undefined
    ------------------
    Battle Athletess 01v2
    6AA7A5A2
    353.016.053
    22/04/2005
    22/04/2005
    undefined
    ------------------





    la ripetizione credo di aver capito da cosa dipenda ma l'undefined no

    e soprattutto al campo testo ho abilitato il multilinea ma non mi va a capo.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2005
    Messaggi
    12

    ultimo aggiornamento

    ultimo aggiornamento

    sono riuscito a fare scrivere nel filmato i valori ma rimane il problema del "a capo" ...

    vi posto i valori aggiornati

    codice:
    filexml = "release.xml";
    
    
    ApriXML();
    function ApriXML () {
    	var mioxml = new XML();
    	var myarray = new Array();
    	mioxml.load(filexml);
    	mioxml.onLoad = ElaboraXML;
    	function ElaboraXML (success) {
    		if (mioxml.loaded) {
    
    
    
    			var myarray = mioxml.firstChild.nextSibling.childNodes;
    
    			trace ("Tot elementi = " + myarray.length);
    
    			for (var i=0;i<=myarray.length;i++){
    
    				if (myarray[i].nodeName == "value"){
    				
    				trace("------------------")
    				
    				trace(myarray[i].attributes.id)				
    				trace(myarray[i].childNodes[1].childNodes.toString())
    				trace(myarray[i].childNodes[3].childNodes.toString())
    				var titolo = trace(myarray[i].childNodes[5].childNodes.toString())
    				titolo.text += myarray[i].childNodes[5].childNodes.toString() + "
    ";
    				//trace("elemento ["+i+"] ------------------")
    				//trace(myarray[i])
    											}
                    
    												}
    		}
    		;
    	}
    	;
    }
    ;
    e vi metto delle immagini di come ho impostato il campo testo e di come mi risulta al debug.






    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.