Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826

    parsing xml ff chrome safari

    ciao .
    Devo effettuare il parsing di un xml in modo compatibile su chrome , ff e safari .
    Adesso uso questo metodo con il dom su ff ma mi sembra non funzionare su chrome e safari.
    chiedo a voi , c'è un errore di compatibilità?
    come posso risolvere?
    grazie.

    codice:
    function ReadXmlFile() {
        
        var m_scene = [];
        
    }
    ReadXmlFile.prototype = {
    
        load: function (render) {
            
            m_scene = new Array();
            xmlDoc = document.implementation.createDocument("", "", null);
            
            xmlDoc.async = false;
            xmlDoc.load("test.xml");
            readXMLFile(render);
    
        },
        GetScene: function () {
         
            return m_scene;
        }
    }
    
    function readXMLFile(render) {
    
        var path = "/Root/Batches/Batch/Positions";
        var nodes1 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
            
        path = "/Root/Batches/Batch/Normals";
        nodes2 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        
        path = "/Root/Batches/Batch/UVFront";
        nodes3 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        
    
        path = "/Root/Batches/Batch/UVBack";
        nodes4 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    
        path = "/Root/Batches/Batch/TextureFront";
        nodes5 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    
        path = "/Root/Batches/Batch/TextureBack";
        nodes6 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    
        path = "/Root/Batches/Batch/ColorFront";
        nodes7 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    
        path = "/Root/Batches/Batch/ColorBack";
        nodes8 = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    
        path = "/Root/Textures";
        
        var nodesTextures = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        var strTextures = nodesTextures.snapshotItem(0).textContent.split(";");
    
        for (var k = 0; k < strTextures.length; k++) {
           render.GetTextureManager().initTexture("TexturesModel/" + strTextures[k]);
        }
         
        var path = "/Root/BVV";
        var nodesPos = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        if (nodesPos.snapshotItem(0).textContent != "") {
            var str = nodesPos.snapshotItem(0).textContent.split(" ");
            m_Pos[0] = parseFloat(str[0]);
            m_Pos[1] = parseFloat(str[1]);
            m_Pos[2] = parseFloat(str[2]);
            
        }
    //ecc... per gli altri dati
    alla fine prendo snapshotItem(0) o n e passo una serie di dati 1 2 3 4 5 separati da " " alla classe che crea i miei oggetti e termina il parsing oppure termino direttamente il parsing nell oggetto leggendo le mie variabili come per BVV(sta per bounding volume).
    grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    up.

  3. #3
    Io di solito il parsing di XML lo faccio con jQuery così non ho problemi di compatibilità cross-browser.
    max

    Silence is better than bullshit.
    @mmarcon
    jHERE, Maps made easy

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    grazie .
    Soluzione intelligente.

  5. #5
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    non ho capito una cosa:
    come si usano i selectors ?:
    devo immagazzinare in una variabile tutti i tag Data con jqueery di questo semplice xml:
    codice:
    <root>
       <mesh>
          <Data1>1 1 1 1 1 1 1</Data1>
          <Data2>2 2 2 2 2 2 2</Data2>
       </mesh>
       <mesh>
          <Data1>3 3 3 3 3 3 3</Data1>
          <Data2>4 4 4 4 4 4 4</Data2>
       </mesh>
    
    </root>
    vorrei avere nelle 4 variabili :
    var AData1 = 1 1 1 1 1 1 1
    var AData2 = 2 2 2 2 2 2 2
    var BData1 = 3 3 3 3 3 3 3
    var BData2 = 4 4 4 4 4 4 4

    o meglio

    avere un cursore per scorrere i selectors e utilizzare ad es due var mesh1 e mesh2 ciscuna con due record.


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