Re: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Peter Hall

(static functions recurse faster).



Really??


Peter
___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Steven Sacks
XML2AS is the best one I've found.  It's also the fastest.  I didn't 
write it, but I have included it in my package of data tools.


It creates String objects out of nodes and applies attributes and the 
names of the child nodes as array properties.


I have written about it on many occasions on Flashcoders.  Search the 
archives and you'll find stuff.  Here's the compacted version of the 
method converted to a static AS2 class (static functions recurse faster).



class net.stevensacks.data.XML2AS
{
public static function parse(n, r) {
var a, d, k;
if (r[k=n.nodeName] == null) r = ((a=r[k]=[{}]))[d=0];
else r = (a=r[k])[d=r[k].push({})-1];
if (n.hasChildNodes()) {
if ((k=n.firstChild.nodeType) == 1) {
r.attributes = n.attributes;
for (var i in k=n.childNodes) XML2AS.parse(k[i], r);
} else if (k == 3) {
a[d] = new String(n.firstChild.nodeValue);
a[d].attributes = n.attributes;
}
}else r.attributes = n.attributes;
}
};


___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Robert Brisita

Ever tried XML2Object?
Check it out:
http://www.sephiroth.it/file_detail.php?id=129

The only draw back is if there is only one element it won't put it into 
an array but an object.  To resolve

this I throw it into an array to unify use:

if(!object.xml_element.length)
{
   object.xml_element = new Array(object.xml_element);
}

Ciao,
Rob.

Johannes Nel wrote:

xpath statement to get all the artist names "./root/track/artist/text()"

On 5/3/07, Johan Nyberg <[EMAIL PROTECTED]> wrote:


Hi, what I need is basically a class that puts all the data in an
associative array, or numeric, depending on if I'm storing values for
individual nodes, or a "mothernode".

Now I find there is a lot of looping going on every time I have to parse
a XML, and XPath seems more like the thing you want to use if you're
looking for specific data inside the XML - I just want to put all the
data in an Array or Object...

For example:














I would like it like this: root[track[n]["artist"]]

Regards,

/Johan

--
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm
070 - 407 83 00

___
Flashcoders@chattyfig.figleaf.com
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







___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Norman Cousineau
Here's what I use:
My example creates an array containing 3 items. Each item is an object that has 
3 properties (vidpath, otherAttribute, description). It creates properties from 
the xml attributes and the value of the child nodes.

Given an xml file such as:


Text description 
1
Text description 
2
Text description 
3


The ActionScript:

var flv_data_xml:XML = new XML();
flv_data_xml.ignoreWhite = true;
flv_data_xml.onLoad = function(success:Boolean) {
var theList:Array = Array();
if (success) {
AllNodeAtts = Array();
for (var theNode:XMLNode = this.firstChild.firstChild; theNode 
!= null; theNode=theNode.nextSibling) {
var IndivNodeAtts:Object = new Object();
//create a propertay called "description" and insert 
the value of the child node.
IndivNodeAtts.description = theNode.firstChild;
for (attr in theNode.attributes) {
IndivNodeAtts[attr] = theNode.attributes[attr];
}
AllNodeAtts.push(IndivNodeAtts);
}
trace(AllNodeAtts[0].vidpath);
trace(AllNodeAtts[1].otherAttribute);
trace(AllNodeAtts[2].description);
//  output:
//  video1.flv
//  oa2
//  Text description 3
} else {
// error loading xml
}
};
flv_data_xml.load("flv_data_example.xml");



Norm C

-Original Message-
From: Johan Nyberg [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 10:15 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Any good XML api out there?


Hi, what I need is basically a class that puts all the data in an 
associative array, or numeric, depending on if I'm storing values for 
individual nodes, or a "mothernode".

Now I find there is a lot of looping going on every time I have to parse 
a XML, and XPath seems more like the thing you want to use if you're 
looking for specific data inside the XML - I just want to put all the 
data in an Array or Object...

For example:














I would like it like this: root[track[n]["artist"]]

Regards,

/Johan

-- 
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm 
070 - 407 83 00


___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Ron Wheeler
Create a Track object which has "name" and "artist"" properties. Write 1 
line simple setters and getters and a constructor that takes an XML 
subtree and extracts the Track detail (This way you can add more to the 
track without having to touch anyone else.)


Create a "root" object that has a list of Track objects and a method 
getTrack(n) that returns the nth track.
The constructor for Root takes the XML as an argument and creates an 
array of Track Objects by passing in the sub-tree for each track when it 
finds one in the XML tree.


artistName=root.getTrack(2).getArtistName();

Very simple code. Easy to debug and maintain.

Ron

Johan Nyberg wrote:
Hi, what I need is basically a class that puts all the data in an 
associative array, or numeric, depending on if I'm storing values for 
individual nodes, or a "mothernode".


Now I find there is a lot of looping going on every time I have to 
parse a XML, and XPath seems more like the thing you want to use if 
you're looking for specific data inside the XML - I just want to put 
all the data in an Array or Object...


For example:



   
   



   
   




I would like it like this: root[track[n]["artist"]]

Regards,

/Johan


___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Johannes Nel

xpath statement to get all the artist names "./root/track/artist/text()"

On 5/3/07, Johan Nyberg <[EMAIL PROTECTED]> wrote:


Hi, what I need is basically a class that puts all the data in an
associative array, or numeric, depending on if I'm storing values for
individual nodes, or a "mothernode".

Now I find there is a lot of looping going on every time I have to parse
a XML, and XPath seems more like the thing you want to use if you're
looking for specific data inside the XML - I just want to put all the
data in an Array or Object...

For example:














I would like it like this: root[track[n]["artist"]]

Regards,

/Johan

--
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm
070 - 407 83 00

___
Flashcoders@chattyfig.figleaf.com
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





--
j:pn
http://www.lennel.org
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Any good XML api out there?

2007-05-03 Thread Norman Cousineau
Here's what I use:


-Original Message-
From: Johan Nyberg [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 03, 2007 10:15 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] Any good XML api out there?


Hi, what I need is basically a class that puts all the data in an 
associative array, or numeric, depending on if I'm storing values for 
individual nodes, or a "mothernode".

Now I find there is a lot of looping going on every time I have to parse 
a XML, and XPath seems more like the thing you want to use if you're 
looking for specific data inside the XML - I just want to put all the 
data in an Array or Object...

For example:














I would like it like this: root[track[n]["artist"]]

Regards,

/Johan

-- 
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm 
070 - 407 83 00


___
Flashcoders@chattyfig.figleaf.com
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


[Flashcoders] Any good XML api out there?

2007-05-03 Thread Johan Nyberg
Hi, what I need is basically a class that puts all the data in an 
associative array, or numeric, depending on if I'm storing values for 
individual nodes, or a "mothernode".


Now I find there is a lot of looping going on every time I have to parse 
a XML, and XPath seems more like the thing you want to use if you're 
looking for specific data inside the XML - I just want to put all the 
data in an Array or Object...


For example:



   
   



   
   




I would like it like this: root[track[n]["artist"]]

Regards,

/Johan

--
Johan Nyberg

Web Guide Partner
Sergels Torg 12, 8 tr
111 57 Stockholm 
070 - 407 83 00


___
Flashcoders@chattyfig.figleaf.com
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