Re: [flexcoders] += operator is changing the encodings

2006-10-28 Thread Luis Eduardo


  wow gordon!
  i am completly newbie on flex but understood perfectly your explanations!

  this should be putted on the help of += operator  :)

  thank you very much dude!


  []'s

   Luís Eduardo



Gordon Smith escreveu:

> You're running into a difference between an XMLList (a built-in E4X 
> type, along with the XML type) and XMLListCollection (a Flex framework 
> type).
>
>  
>
> If the right-hand-side (RHS) of the E4X += operator is an XML instance 
> or an XMLList instance, it inserts children as you are expecting.
>
>  
>
> For example, suppose var x:XML = .
>
>  
>
> Then x.b +=  sets x to . (This is the case where 
> RHS is an XML instance.)
>
>  
>
> And x.b += <> sets x to . (This is the 
> case where RHS is an XMLList instance.)
>
>  
>
> (Note that you can't write an XMLList literal as ; it doesn't 
> compile. You  wrap the nodes of the list between <> and .)
>
>  
>
> However, if the RHS is any other type, then it calls toString() on the 
> RHS and inserts it as text, not as child nodes.
>
>  
>
> For eample, x.b += "foo" sets x to foo.
>
>  
>
> You can't have < and > in XML text, so they get converted to the XML 
> escape entities < and >
>
>  
>
> For example, x.b += "" sets x to <c/> .
>
>  
>
> Since E4X doesn't know about XMLListCollection, it treats it like any 
> other type and converts your XMLLC to a string and then escapes it. I 
> don't know of any way to directly convert an XMLListCollection to an 
> XMLList without looping over the items, which is similar to what 
> you're doing extract one XML from the XMLListCollection at a time.
>
>  
>
> - Gordon
>
>  
>
> ----------------
>
> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
> *On Behalf Of *Luis Eduardo
> *Sent:* Wednesday, October 25, 2006 12:33 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* Re: [flexcoders] += operator is changing the encodings
>
>  
>
>
>
> Igor,
>
> thx for your answer, but i think something isnt clear...
>
> my problem is on the += operator in this line of code:
>
> xgravar.root.request += XMLLC;
>
> the XMLLC object is declared as:
>
>  collectionChange="collectionEventHandler(event)"/>
>
> and have, at the time this line of code fire, the follow XML
>
> 
> 
> 
> 
>
> just that. (without a root node).
>
> the root node is at "xgravar.request".
>
> but, when i do:
>
> xgravar.root.request += XMLLC;
>
> and after Alert.show(xgravar.toXMLString()) the code is changed to:
>
> 
> 
> 
> <TipoVeiculo Id="1" Nome="Moto" Descricao="desc">
> <TipoVeiculo Id="2" Nome="Carro" Descricao="desc">
> <TipoVeiculo Id="3" Nome="Caminhao" Descricao="desc">
> <TipoVeiculo Id="4" Nome="Aviao" Descricao="desc">
> 
> 
> 
>
> i have made a workaround for this with the follow code:
>
> for each( var item : XML in XMLLC ) {
> XML(xgravar.root.request).appendChild(item);
> }
>
> but i think that the += operator SHOULD do the same thing WITHOUT
> changing the < and > simbols.
>
> dont you agree?
>
> best regards to you!
>
> Luís Eduardo.
>
> Igor Costa escreveu:
>
>> Hi Luiz
>>
>>
>> Isn't the operator that's wrong, you just missed out how to pass
>> String and concatening in both side of wall.
>>
>> Check out this heck of how could be done.
>>
>> public function myList():void
>> {
>> var myXML = new
>> XMLList("");
>> szCommand = "insert";
>> if( [EMAIL PROTECTED] = szCommand == true)
>> {
>> Alert.show(xgravar.toString());
>> }
>> else {
>> Alert.show(xgravar);
>> }
>> }
>>
>>
>> The problem is, you are trying to convert an object twice in time in
>> the same function, that's why the problem happens. if you put anything
>> in braces <> than you convert to string, the compiler intend to
>> undrestand that, "ok the users now want to convert that cacharecter".
>>
>>
>> Regards.
>>
>> szCommand = "insert";
>> [EMAIL PROTECTED] = szCommand;
>>
>> Alert.show(XMLLC.toXMLString()); // OK here. all < and >
>> works fine
>>
>> xgravar.root.request += XMLLC;
>>
>> Alert.show(xgravar.toXMLString()); // ERROR h

RE: [flexcoders] += operator is changing the encodings

2006-10-25 Thread Gordon Smith












You're running into a difference between an XMLList (a
built-in E4X type, along with the XML type) and XMLListCollection (a Flex
framework type).

 

If the right-hand-side (RHS) of the E4X += operator is an
XML instance or an XMLList instance, it inserts children as you are expecting.

 

For example, suppose var x:XML = .

 

Then x.b +=  sets x to .
(This is the case where RHS is an XML instance.)

 

And x.b += <> sets x to
. (This is the case where RHS
is an XMLList instance.)

 

(Note that you can't write an XMLList literal as
; it doesn't compile. You  wrap the nodes of the list
between <> and .)

 

However, if the RHS is any other type, then it calls
toString() on the RHS and inserts it as text, not as child nodes.

 

For eample, x.b += "foo" sets x to
foo.

 

You can't have < and > in XML text, so they get
converted to the XML escape entities < and >

 

For example, x.b += "" sets x to <c/>
.

 

Since E4X doesn't know about XMLListCollection, it treats it
like any other type and converts your XMLLC to a string and then escapes it. I
don't know of any way to directly convert an XMLListCollection to an XMLList
without looping over the items, which is similar to what you're doing extract
one XML from the XMLListCollection at a time.

 

- Gordon



 









From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Luis Eduardo
Sent: Wednesday, October 25, 2006
12:33 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] +=
operator is changing the encodings



 









Igor,

thx for your answer, but i think something isnt clear...

my problem is on the += operator in this line of code:

xgravar.root.request += XMLLC;

the XMLLC object is declared as:

on id="XMLLC" 
collectionChange="collectionEventHandler(event)"/>

and have, at the time this line of code fire, the follow XML

Nome="Moto"
Descricao="desc">
Nome="Carro"
Descricao="desc">
Nome="Caminhao"
Descricao="desc">
Nome="Aviao"
Descricao="desc">

just that. (without a root node).

the root node is at "xgravar.request".

but, when i do:

xgravar.root.request += XMLLC;

and after Alert.show(xgravar.toXMLString()) the code is changed to:




<TipoVeiculo Id="1" Nome="Moto"
Descricao="desc">
<TipoVeiculo Id="2" Nome="Carro"
Descricao="desc">
<TipoVeiculo Id="3" Nome="Caminhao"
Descricao="desc">
<TipoVeiculo Id="4" Nome="Aviao"
Descricao="desc">




i have made a workaround for this with the follow code:

for each( var item : XML in XMLLC ) {
XML(xgravar.root.request).appendChild(item);
}

but i think that the += operator SHOULD do the same thing WITHOUT 
changing the < and > simbols.

dont you agree?

best regards to you!

Luís Eduardo.

Igor Costa escreveu:

> Hi Luiz
>
>
> Isn't the operator that's wrong, you just missed out how to pass 
> String and concatening in both side of wall.
>
> Check out this heck of how could be done.
>
> public function myList():void
> {
> var myXML = new 
> XMLList("></dsRQ>");
> szCommand = "insert";
> if( xgravar.request.@command = szCommand == true)
> {
> Alert.show(xgravar.toString());
> }
> else {
> Alert.show(xgravar);
> }
> }
>
>
> The problem is, you are trying to convert an object twice in time in 
> the same function, that's why the problem happens. if you put anything 
> in braces <> than you convert to string, the compiler intend to 
> undrestand that, "ok the users now want to convert that cacharecter".
>
>
> Regards.
>
> szCommand = "insert";
> xgravar.root.request.@command = szCommand;
>
> Alert.show(XMLLC.toXMLString()); // OK here. all < and >
> works fine
>
> xgravar.root.request += XMLLC;
>
> Alert.show(xgravar.toXMLString()); // ERROR here. < and >
> converted to < and >
> }
>
>
>
>
>
>
>
> On 10/24/06, *Luis Eduardo* <illogic_code@yahoo.com.br

> illogic_code@yahoo.com.br>>
wrote:
>
>
> hi,
>
> In my app, when i use the += operator, the data inside xmls turns
> with
> diferent encoding.
> The < and > caracters become wierds like < and >
respectively.
>
> How can i fix this?
>
> this is the code:
>
> public function doGravar():void {
> var xgravar:XMLList = new
> XMLList("></dsRQ>");
>
> szCommand = "insert";
> xgravar.root.request.@command = szCommand;
>
> Alert.show(XMLLC.toXMLString()); // OK here. all < and >
> works fine
>
&g

Re: [flexcoders] += operator is changing the encodings

2006-10-25 Thread Luis Eduardo


  Igor,

  thx for your answer, but i think something isnt clear...

  my problem is on the += operator in this line of code:

   xgravar.root.request += XMLLC;


  the XMLLC object is declared as:



and have, at the time this line of code fire, the follow XML






just that. (without a root node).

the root node is at "xgravar.request".

but, when i do:

xgravar.root.request += XMLLC;

and after Alert.show(xgravar.toXMLString()) the code is changed to:


  

  
  
  
  

  


i have made a workaround for this with the follow code:

for each( var item : XML in XMLLC ) {
XML(xgravar.root.request).appendChild(item);
}

but i think that the += operator SHOULD do the same thing WITHOUT 
changing the < and > simbols.

dont you agree?

best regards to you!

 Luís Eduardo.



Igor Costa escreveu:

> Hi Luiz
>
>
> Isn't the operator that's wrong, you just missed out how to pass 
> String and concatening in both side of wall.
>
> Check out this heck of how could be done.
>
> public function myList():void
> {
>var myXML = new 
> XMLList("");
>szCommand = "insert";
>if( [EMAIL PROTECTED] = szCommand == true)
>   {
>   Alert.show(xgravar.toString());
>}
>  else {
>  Alert.show(xgravar);
>   }
> }
>
>
> The problem is, you are trying to convert an object twice in time in 
> the same function, that's why the problem happens. if you put anything 
> in braces <> than you convert to string, the compiler intend to 
> undrestand that, "ok the users now want to convert that cacharecter".
>
>
> Regards.
>
> szCommand = "insert";
> [EMAIL PROTECTED] = szCommand;
>
> Alert.show(XMLLC.toXMLString()); // OK here. all < and >
> works fine
>
> xgravar.root.request += XMLLC;
>
> Alert.show(xgravar.toXMLString()); // ERROR here. < and >
> converted to < and >
> }
>
>
>
>
>
>
>
> On 10/24/06, *Luis Eduardo* <[EMAIL PROTECTED] 
> > wrote:
>
>
> hi,
>
> In my app, when i use the += operator, the data inside xmls turns
> with
> diferent encoding.
> The < and > caracters become wierds like < and > respectively.
>
> How can i fix this?
>
> this is the code:
>
> public function doGravar():void {
> var xgravar:XMLList = new
> XMLList("");
>
> szCommand = "insert";
> [EMAIL PROTECTED] = szCommand;
>
> Alert.show(XMLLC.toXMLString()); // OK here. all < and >
> works fine
>
> xgravar.root.request += XMLLC;
>
> Alert.show(xgravar.toXMLString()); // ERROR here. < and >
> converted to < and >
> }
>
> where XMLLC : XMLListCollection and szCommand : String.
> The first Alert will show correct data but the second will show
> caracters converted.
>
> regards,
>
> Luís Eduardo.
>
>
> ___
> Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu
> celular. Registre seu aparelho agora!
> http://br.mobile.yahoo.com/mailalertas/
> 
>
>
>
>
>
> -- 
> 
> Igor Costa
> www.igorcosta.com 
>  




___ 
O Yahoo! est� de cara nova. Venha conferir! 
http://br.yahoo.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



Re: [flexcoders] += operator is changing the encodings

2006-10-25 Thread Igor Costa



Hi LuizIsn't the operator that's wrong, you just missed out how to pass String and concatening in both side of wall.Check out this heck of how could be done.public function myList():void{
   var myXML = new XMLList("");   szCommand = "insert";   if( [EMAIL PROTECTED] = szCommand == true)
  {  Alert.show(xgravar.toString());   }  else { Alert.show(xgravar);  }}The problem is, you are trying to convert an object twice in time in the same function, that's why the problem happens. if you put anything in braces <> than you convert to string, the compiler intend to undrestand that, "ok the users now want to convert that cacharecter".
Regards.
szCommand = "insert";
[EMAIL PROTECTED] = szCommand;
   
Alert.show(XMLLC.toXMLString());  // OK here. all < and > 
works fine
   
xgravar.root.request += XMLLC;
   
Alert.show(xgravar.toXMLString()); // ERROR here. < and > 
converted to < and >
}On 10/24/06, Luis Eduardo <[EMAIL PROTECTED]> wrote:













  




  hi,

In my app, when i use the += operator, the data inside xmls turns with 
diferent encoding.
  The < and > caracters become wierds like < and > respectively.

How can i fix this?

this is the code:

public function doGravar():void {
var xgravar:XMLList = new 
XMLList("");

szCommand = "insert";
[EMAIL PROTECTED] = szCommand;
   
Alert.show(XMLLC.toXMLString());  // OK here. all < and > 
works fine
   
xgravar.root.request += XMLLC;
   
Alert.show(xgravar.toXMLString()); // ERROR here. < and > 
converted to < and >
}

where XMLLC : XMLListCollection  and szCommand : String.
The first Alert will show correct data but the second will show 
caracters converted.

regards,

Luís Eduardo.

		
___ 
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora! 
http://br.mobile.yahoo.com/mailalertas/ 
 



  













-- Igor Costawww.igorcosta.com

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Software development tool
  
  
Software development
  
  
Software development services
  
  


Home design software
  
  
Software development company
  

   
  






  
  Your email settings: Individual Email|Traditional 
  Change settings via the Web (Yahoo! ID required) 
  Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured 
   
Visit Your Group 
   |
  
Yahoo! Groups Terms of Use
   |
  
   Unsubscribe 
   
 

  




__,_._,___