Use json or eden ... you can use it in XML to with a deserialization of the
nodes ;)

x = new XML("<xml><item>{ prop1:"item1", prop2:"item2" }</item></xml>") ;

you can use JSON.deserialize( x.firstChild.firstChild.firstChild.nodeValue )
; // it's an example not tested !

EKA+ :)

2006/11/16, Rich Rodecker <[EMAIL PROTECTED]>:

julien:

sure here's a sample:

class com.mysite.model.Settings {

    private static var instance = null;

    public var custom_color_3:String;
    public var background_image:Boolean;
    public var background_type:String;
    public var background_alpha:Number;
    public var title_mode:String;

    //rest of class....
}

Here is the function where I parse the xml into the properties above,
pretty
simple:

    function parseSettings(){

        var settingsBranch = app_xml.firstChild.firstChild;
        var c = settingsBranch.childNodes;

        var num = settingsBranch.childNodes.length;

        var nextBranch:XMLNode = settingsBranch.childNodes[0];

        while(nextBranch){
            var tagName = nextBranch.nodeName;
            settings[tagName] = nextBranch.firstChild.nodeValue;
            nextBranch = nextBranch.nextSibling;
        }

    }


and here is what the xml looks like:
    <settings>
        <custom_color_3>#FFFFFF</custom_color_3>
        <background_image>1</background_image>
        <background_type>jpg</background_type>
        <background_alpha>100</background_alpha>
        <title_mode>PROFILE</title_mode>
    </settings>



eka:  - yeah, i know xml is only a string..my problem is that i am
assigning
a string to properties that are clearly typed as something other than a
string, yet flash isnt complaining.




On 11/16/06, eka <[EMAIL PROTECTED]> wrote:
>
> Hello :)
>
> a XML is only a String .... all properties (nodeValue) or attributes are
> strings... you must transform the type of your values with customs
> "deserialize" functions.
>
> For me it's better to use JSON for example : http://www.json.org/ (you
> keep
> the primitive types of your objects with the serialize/deserialize)
>
> You can try to use my openSource framework "VEGAS" who implement JSON
and
> EDEN (the best solution to text format datas)
>
> Install VEGAS : http://vegas.riaforge.org/ (use the SVN or the zip link
in
> this page to download my framework)
>
> Test the JSON examples in VEGAS in the vegas.string package :
> http://svn.riaforge.org/vegas/AS2/trunk/bin/test/vegas/string/
>
> Test the Eden examples (Burrrn library used in VEGAS) :
> http://svn.riaforge.org/vegas/AS2/trunk/bin/test/buRRRn/eden/
>
> Test JSON and Eden extension in ASGard (extension of VEGAS) :
> http://svn.riaforge.org/vegas/AS2/trunk/bin/test/asgard/net/(JSONLoader,
> EdenLoader)
>
> Test my example of Config pattern and localization pattern in
> http://svn.riaforge.org/vegas/AS2/trunk/bin/test/asgard/config/ (and
> bin/test/system)
>
> For me ... XML is slow and don't keep the typing  !
>
> EKA+ :)
>
>
> 2006/11/16, Julien Vignali <[EMAIL PROTECTED]>:
> >
> > Hi Rich, could you provide some sample code of your Settings class and
> > your
> > xml processing ?
> >
> > 2006/11/16, Rich Rodecker <[EMAIL PROTECTED]>:
> > >
> > > Hello,
> > >
> > > I've got a class named 'Settings' which has a number of
> > properties.  Those
> > > properties are strongly typed to various types...string, number,
> > boolean,
> > > etc.
> > >
> > > I'm loading in xml in a separate Model class, and then parsing the
xml
> > and
> > > assigning the that various values in the xml to the properties of
the
> > > Settings class.  However, all the values are being set as a string
> (that
> > > part I expected since I am assigning the  values of text nodes,
which
> of
> > > course are strings, in the xml to the Setting's properties)...and
I'm
> > not
> > > getting any parse errors when I try and assign a string to a
property
> > that
> > > is strongly typed as a number, or boolean.
> > >
> > > I figure since I am trying to use myBranch.firstChild.nodeValue that
> > > flash,
> > > at compile time, can see I am trying to set a string to a property
> typed
> > > as
> > > a Number, so what's going on?
> > > _______________________________________________
> > > [email protected]
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> > >
> > _______________________________________________
> > [email protected]
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to