16 Replies Latest reply on Jul 25, 2009 3:34 AM by Adriano_82

    Shopping cart XML, problems with REAL(R$0.000,00) money

    Adriano_82 Level 1

      Now, I have a small problem. (But I think it's big)

      I can perfectly read the items(I had some help), but the values, I can not read the values in real(R$) money, or can not read R$ 1.855,34

      I just read removing a point and removing the comma by replacing point, example: 1855.34

      Somebody know how can I do that, show the value in real R$ 1.855,34 ?

      XML:
      <carrinho>
           <carrinhoQTD>
               <item>1</item>
               <valor>0,01</valor>
           </carrinhoQTD>
           <carrinhoQTD>
               <item>1</item>
               <valor>65,88</valor>
           </carrinhoQTD>
           <carrinhoQTD>
               <item>3</item>
               <valor>1.789,45</valor>
           </carrinhoQTD>
      </carrinho>

       

      AS:
      function loadXML(loaded) {
           if (loaded) {
               xmlNode = this.firstChild;
               item = [];
               valor = [];
               total = xmlNode.childNodes.length;
               for (i=0; i<total; i++) {
                   item[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                   valor[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
               }
               mostrarCarrinho();
           } else {
               content = "não carregou!";
           }
      }
      xmlData = new XML();
      xmlData.ignoreWhite = true;
      xmlData.onLoad = loadXML;
      xmlData.load("images.xml");
      //
      function mostrarCarrinho() {    
         var tempItens:Number = 0;    
         var tempValor:Number = 0;    
         var _string:String;    
         var _array:Array;    
         for(var i = 0; i<item.length; i++){        
           tempItens += Number(item[i]);        
           // the following two lines remove all points
           _array = valor[i].split('.');
           _string = _array.join('');
           // the following two lines replaces all commas with points
           _array = _string.split(',');
           _string = _array.join('.');
           tempValor += Number(_string);
           }
         itens_txt.text = tempItens;
         valor_txt.text = tempValor;
      }

       

       

      or another way?

       

      Thanks