Hi Jeff,
if you want to convert the XML to anative AS object you could try out
Sephiroth's XML2Object class
http://www.sephiroth.it/file_detail.php?pageNum_comments=0&id=129
or the XMLObject class which is similar but with a few more
functionnalities.
http://www.sephiroth.it/file_detail.php?id=134#
import it.sephiroth.XML2Object;
var XML_FILE:String = "http://my.server.com/myapp/xmlfile" +
i_id + ".xml";
var oXML:XML = new XML();
var ObjFromXML:XML2Object = new XML2Object();
var myObject:Object = new Object();
var thisRef = this;
oXML.ignoreWhite = true;
oXML.onLoad = function(success) {
if (success) {
myObject = ObjFromXML.parseXML(oXML);
thisRef.accessObject();
}else{
//you error code here
}
};
oXML.load(XML_FILE);
function accessObject():Void {
var i:Number = -1;
while (++i < myObject.bgColor.length) {
trace("bgColor = "+myObject.bgColor[i]); // if you have
more than one bgColor tag in your XML, the class will convert it to an array
}
}
This is an example of what you can do with that class. This would save
you the time of creating your own Object.
HTH
Alain
Jeff Brown wrote:
Thanks Mike!
That looks like something I can tweak.
But, id do still have a question or two.
It seems it might go easier on me if I rdeifine the XML to use just child
nodes instead of attributes. Does that make sense, or is there an easier
way to get at an attribute of your array then say:
var g_id:Number = itemAr[i].firstChild.attribute.group.nodeValue;
var bgcolor:String =
groupAr[g_id].firstChild.attribute.bgcolor.nodeValue;
I mean, I did a little searching on the web and found some XPath
documentation, thanks to Ramon's note, so is there something like.
var g_id:Number = XPathAPI.selectInteger(itemAr[i], "atribute::lang");
var bgcolor:String = XPathAPI.selectString(groupAr[g_id],
"attribute::bgcolor");
Hmm, even my examples, if they exists, seem verbose. But if it works,
then
I can get the stuff done I need too.
I guess the ideal would be for me to build some 'tweaked' object so
that I
could use.
------------- ideal code ---------------
var data:Data = new Data("http://my.server.com/myapp/xmlfile" + i_id +
".xml");
while (Data.items()) // iterator sets internal pointer to internal item
Array
{
var bgcolor:String = Data.getBgColor(); // for example looks up the
Group
by the current item's group attribute.
...
// build display stuff
}
------------ /ideal code ---------------
If this is just a pipe dream, let me know. I think something like my
ideal
code example above would work great, because I won't be building the
flash
for the application, and my flash designer is a little leary of
actionscripting. And I knew conceptually that flash could read XML.
If I
can give her an object like that, then I know she can build what we need.
Thanks
Jeff
On 8/31/06, Mike Britton <[EMAIL PROTECTED]> wrote:
It's built into Flash 8:
import mx.xpath.XPathAPI;
function getXMLData() {
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success:Boolean) {
if (success) {
var groupAr:Array = XPathAPI.selectNodeList(
this.firstChild,
"/data/grouplist/group");
var itemAr:Array = XPathAPI.selectNodeList(
this.firstChild,
"/data/itemList/item");
for (var i:Number=0; i<groupAr.length; i++) {
trace(groupAr[i].firstChild.nodeValue);
}
for (var i:Number=0; i<itemAr.length; i++) {
trace(itemAr[i].firstChild.nodeValue);
}
} else {
trace("XML loading failed !!!");
}
};
myXML.load("myXML.xml");
}
Tweakage may be necessary - I've had a couple glasses of wine.
Mike Britton
_______________________________________________
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
_______________________________________________
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