flash.xml.XML question .

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

flash.xml.XML question .

Fei Yin
When I use Actionscript 3 , I can just find a node very easy . like this :

var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8" src="some/path1.jpg" /> </data>

So i can get <image id="4" src="some/path.jpg" /> just use 
trace(someXML.image.(@id == 4).toXMLString());

But how can I do the same thing in haXe ? I can't simple to use someXML.image[0] for get the image path data for the specification id from database .

--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

Pimm Hogeling
The syntax you're using in ActionScript 3 is E4X (ECMAScript for XML).

haXe has something similar, called the haxe.xml.Fast API. You might want to try that.

On Mon, Jan 11, 2010 at 16:16, 尹飞 <[hidden email]> wrote:
When I use Actionscript 3 , I can just find a node very easy . like this :

var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8" src="some/path1.jpg" /> </data>

So i can get <image id="4" src="some/path.jpg" /> just use 
trace(someXML.image.(@id == 4).toXMLString());

But how can I do the same thing in haXe ? I can't simple to use someXML.image[0] for get the image path data for the specification id from database .

--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

clemos
In reply to this post by Fei Yin
There is no such syntax in haXe, but you can give haxe.xml.Fast a try :
http://haxe.org/doc/advanced/xml_fast

Something like :
var data = new haxe.xml.Fast( someXML.firstElement() );
var images = new Array<Fast>();
for( image in data.nodes.image ){
   // index images by id
   images[image.att.id] = image;
   // trace node content
   trace("Image #" + image.att.id + " : src = " + image.att.src);
}

++++++++
Clément

On Mon, Jan 11, 2010 at 4:16 PM, 尹飞 <[hidden email]> wrote:

> When I use Actionscript 3 , I can just find a node very easy . like this :
> var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8"
> src="some/path1.jpg" /> </data>
> So i can get <image id="4" src="some/path.jpg" /> just use
> trace(someXML.image.(@id == 4).toXMLString());
> But how can I do the same thing in haXe ? I can't simple to use
> someXML.image[0] for get the image path data for the specification id from
> database .
> --
> Best regards
>
> Yin Fei
>
> From Icebirds.net
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

Fei Yin
In reply to this post by Pimm Hogeling
I have read it . but I still don't know how to get some xml node like .(@id == somevalue) .

Could you please teach me this ?

2010/1/11 Pimm Hogeling <[hidden email]>
The syntax you're using in ActionScript 3 is E4X (ECMAScript for XML).

haXe has something similar, called the haxe.xml.Fast API. You might want to try that.

On Mon, Jan 11, 2010 at 16:16, 尹飞 <[hidden email]> wrote:
When I use Actionscript 3 , I can just find a node very easy . like this :

var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8" src="some/path1.jpg" /> </data>

So i can get <image id="4" src="some/path.jpg" /> just use 
trace(someXML.image.(@id == 4).toXMLString());

But how can I do the same thing in haXe ? I can't simple to use someXML.image[0] for get the image path data for the specification id from database .

--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

Cauê W.
Hey, you can have a look at away3dlite's port to haXe ( here : http://code.google.com/p/away3d/source/browse/trunk/haxe/Away3DLite/debug/away3dlite/haxeutils/xml/E4X.hx ) . It provides a simple, non-crossplatform (yet) way to use basically the same syntax as in as3. In the collada parser you can see how to use it, but basically:


using away3dlite.haxeutils.xml.E4X;

var someXML:XML = new XML('<data> <image id="4" src="some/path.jpg" /> <image id="8" src="some/path1.jpg" /> </data>');

//trace(someXML.image.(@id == 4).toXMLString());
//will become:

trace(someXML.image._filter_eq("@id", 4).toXMLString());

//or :

trace(someXML.image._filter("@id", 4, function(a, b) { return a == b; } ).toXMLString());

2010/1/11 尹飞 <[hidden email]>
I have read it . but I still don't know how to get some xml node like .(@id == somevalue) .

Could you please teach me this ?

2010/1/11 Pimm Hogeling <[hidden email]>

The syntax you're using in ActionScript 3 is E4X (ECMAScript for XML).

haXe has something similar, called the haxe.xml.Fast API. You might want to try that.

On Mon, Jan 11, 2010 at 16:16, 尹飞 <[hidden email]> wrote:
When I use Actionscript 3 , I can just find a node very easy . like this :

var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8" src="some/path1.jpg" /> </data>

So i can get <image id="4" src="some/path.jpg" /> just use 
trace(someXML.image.(@id == 4).toXMLString());

But how can I do the same thing in haXe ? I can't simple to use someXML.image[0] for get the image path data for the specification id from database .

--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org



--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

Fei Yin
In reply to this post by clemos
Thanks ! 

I think that means I must parse the xml data to a Fast type Array first , But if the id values is start from 2000 when get the data from database , this will make lots of undefined elements in the Array . 

2010/1/11 clemos <[hidden email]>
There is no such syntax in haXe, but you can give haxe.xml.Fast a try :
http://haxe.org/doc/advanced/xml_fast

Something like :
var data = new haxe.xml.Fast( someXML.firstElement() );
var images = new Array<Fast>();
for( image in data.nodes.image ){
  // index images by id
  images[image.att.id] = image;
  // trace node content
  trace("Image #" + image.att.id + " : src = " + image.att.src);
}

++++++++
Clément

On Mon, Jan 11, 2010 at 4:16 PM, 尹飞 <[hidden email]> wrote:
> When I use Actionscript 3 , I can just find a node very easy . like this :
> var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image id="8"
> src="some/path1.jpg" /> </data>
> So i can get <image id="4" src="some/path.jpg" /> just use
> trace(someXML.image.(@id == 4).toXMLString());
> But how can I do the same thing in haXe ? I can't simple to use
> someXML.image[0] for get the image path data for the specification id from
> database .
> --
> Best regards
>
> Yin Fei
>
> From Icebirds.net
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

clemos
Array is a possibility, but if your ids are non-continuous, you may
want to use IntHash instead :
var images = new IntHash<Fast>();
...
images.set( Std.parseInt( image.att.id ) , image );
...
+++++++
Clément

2010/1/11 尹飞 <[hidden email]>:

> Thanks !
> I think that means I must parse the xml data to a Fast type Array first ,
> But if the id values is start from 2000 when get the data from database ,
> this will make lots of undefined elements in the Array .
> 2010/1/11 clemos <[hidden email]>
>>
>> There is no such syntax in haXe, but you can give haxe.xml.Fast a try :
>> http://haxe.org/doc/advanced/xml_fast
>>
>> Something like :
>> var data = new haxe.xml.Fast( someXML.firstElement() );
>> var images = new Array<Fast>();
>> for( image in data.nodes.image ){
>>   // index images by id
>>   images[image.att.id] = image;
>>   // trace node content
>>   trace("Image #" + image.att.id + " : src = " + image.att.src);
>> }
>>
>> ++++++++
>> Clément
>>
>> On Mon, Jan 11, 2010 at 4:16 PM, 尹飞 <[hidden email]> wrote:
>> > When I use Actionscript 3 , I can just find a node very easy . like this
>> > :
>> > var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image
>> > id="8"
>> > src="some/path1.jpg" /> </data>
>> > So i can get <image id="4" src="some/path.jpg" /> just use
>> > trace(someXML.image.(@id == 4).toXMLString());
>> > But how can I do the same thing in haXe ? I can't simple to use
>> > someXML.image[0] for get the image path data for the specification id
>> > from
>> > database .
>> > --
>> > Best regards
>> >
>> > Yin Fei
>> >
>> > From Icebirds.net
>> >
>> > --
>> > haXe - an open source web programming language
>> > http://haxe.org
>> >
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
>
> --
> Best regards
>
> Yin Fei
>
> From Icebirds.net
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.xml.XML question .

Fei Yin
Oh, sorry , I haven't seen this class  ! thanks for a lots !

It is ok now ! 

2010/1/12 clemos <[hidden email]>
Array is a possibility, but if your ids are non-continuous, you may
want to use IntHash instead :
var images = new IntHash<Fast>();
...
images.set( Std.parseInt( image.att.id ) , image );
...
+++++++
Clément

2010/1/11 尹飞 <[hidden email]>:
> Thanks !
> I think that means I must parse the xml data to a Fast type Array first ,
> But if the id values is start from 2000 when get the data from database ,
> this will make lots of undefined elements in the Array .
> 2010/1/11 clemos <[hidden email]>
>>
>> There is no such syntax in haXe, but you can give haxe.xml.Fast a try :
>> http://haxe.org/doc/advanced/xml_fast
>>
>> Something like :
>> var data = new haxe.xml.Fast( someXML.firstElement() );
>> var images = new Array<Fast>();
>> for( image in data.nodes.image ){
>>   // index images by id
>>   images[image.att.id] = image;
>>   // trace node content
>>   trace("Image #" + image.att.id + " : src = " + image.att.src);
>> }
>>
>> ++++++++
>> Clément
>>
>> On Mon, Jan 11, 2010 at 4:16 PM, 尹飞 <[hidden email]> wrote:
>> > When I use Actionscript 3 , I can just find a node very easy . like this
>> > :
>> > var someXML:XML = <data> <image id="4" src="some/path.jpg" /> <image
>> > id="8"
>> > src="some/path1.jpg" /> </data>
>> > So i can get <image id="4" src="some/path.jpg" /> just use
>> > trace(someXML.image.(@id == 4).toXMLString());
>> > But how can I do the same thing in haXe ? I can't simple to use
>> > someXML.image[0] for get the image path data for the specification id
>> > from
>> > database .
>> > --
>> > Best regards
>> >
>> > Yin Fei
>> >
>> > From Icebirds.net
>> >
>> > --
>> > haXe - an open source web programming language
>> > http://haxe.org
>> >
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
>
> --
> Best regards
>
> Yin Fei
>
> From Icebirds.net
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Best regards

Yin Fei

From Icebirds.net

--
haXe - an open source web programming language
http://haxe.org