The XML() function will not create an XML class out of an Object.  It
will only return an XML object if the Object contains and XML object.

 

You can look at the XMLEncoder/decoder, or build the xml manually, which
is what I usually do.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of vetricom vetricom
Sent: Wednesday, August 20, 2008 12:07 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: can't get XML working -- please help

 

Hi,

Thanks a lot for your reply. Yes your suggestion did fix the issue.
After some more search on the google, I did find the issue as well. By
default it assigns the root node to the variable.

Related to this, I did find another issue related to this which is
converting an existing object to XML and then accessing it. when I
convert an object, all the object values are assigned as attributes of
the root node.

Here is the sample code

class MyEvent {
   var x:int;
   var y:int;
}

var event1:MyEvent = new MyEvent(10, 10);
var xmlVar:XML = new XML(event1);

When I dump xmlVar, it looks like this [MyEvent x="10" y="10"] and if I
try to access it like this [EMAIL PROTECTED] or xmlVar.attribute("x"), I get the
same error saying syntax error. Howver if I manually create it using xml
notation like <event x="10" y="10" />, [EMAIL PROTECTED] works perfectly. I dont
why it puts "[" instead of "<" when an on object is converted. Any idea
how to resolve this issue?


Thanks a lot again!


--- On Wed, 8/20/08, gabriela.perry <[EMAIL PROTECTED]> wrote:

From: gabriela.perry <[EMAIL PROTECTED]>
Subject: [flexcoders] Re: can't get XML working -- please help
To: flexcoders@yahoogroups.com
Date: Wednesday, August 20, 2008, 9:40 AM

Hi.
A call to the first node (the root) is not necessary.
Try tracing xmlVar.x instead.
Also check these rules for good XML writing at
http://www.w3school s.com/xml/ xml_dtd.asp
<http://www.w3schools.com/xml/xml_dtd.asp> 
Hope it helps :0)

 

 

Reply via email to