Below are examples of my xml and the code I use to parse it.
THIS IS ONE OF MY XML FILES:
<?xml version="1.0" encoding="iso-8859-1"?>
<INTERACTIVE>
<BUTTON title="website" client="CNE"
buttonIMAGE="webSite_CNE.jpg">
<IMAGES>
<IMAGE>website_CNE(1).jpg</IMAGE>
<IMAGE>website_CNE(2).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="direct emails" client="Dell"
buttonIMAGE="directEmail_Dell.jpg">
<IMAGES>
<IMAGE>email_Dell(1).jpg</IMAGE>
<IMAGE>email_Dell(2).jpg</IMAGE>
<IMAGE>email_Dell(3).jpg</IMAGE>
<IMAGE>email_Dell(4).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="enews" client="Dell"
buttonIMAGE="enews_Dell.jpg">
<IMAGES>
<IMAGE>enews_Dell(1).jpg</IMAGE>
<IMAGE>enews_Dell(2).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="corporate website" client="Dell"
buttonIMAGE="webSite_Dell.jpg">
<IMAGES>
<IMAGE>website_Dell(1).jpg</IMAGE>
<IMAGE>website_Dell(2).jpg</IMAGE>
<IMAGE>website_Dell(3).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="band website" client="Dickie Lee Erwin"
buttonIMAGE="webSite_Dickie.jpg">
<IMAGES>
<IMAGE>website_Dickie(1).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="banner ads" client="Hoover's Online"
buttonIMAGE="banners_Hoovers.jpg">
<IMAGES>
<IMAGE>banners_Hoovers(1).jpg</IMAGE>
<IMAGE>banners_Hoovers(2).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="website" client="Impath"
buttonIMAGE="webSite_Impath.jpg">
<IMAGES>
<IMAGE>website_Impath(1).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="website" client="Radiant Research"
buttonIMAGE="webSite_Radiant.jpg">
<IMAGES>
<IMAGE>website_Radiant(1).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="brand guidelines" client="Temple Inland"
buttonIMAGE="webSite_Inland.jpg">
<IMAGES>
<IMAGE>website_Inland(1).jpg</IMAGE>
<IMAGE>website_Inland(2).jpg</IMAGE>
<IMAGE>website_Inland(3).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="snapshot metrics" client="Tocquigny"
buttonIMAGE="Metrics.jpg">
<IMAGES>
<IMAGE>website_Metrics(1).jpg</IMAGE>
<IMAGE>website_Metrics(2).jpg</IMAGE>
<IMAGE>website_Metrics(3).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="website" client="Tocquigny"
buttonIMAGE="webSite_Tocquigny.jpg">
<IMAGES>
<IMAGE>website_Tocquigny(1).jpg</IMAGE>
<IMAGE>website_Tocquigny(2).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="direct email" client="Toshiba"
buttonIMAGE="directEmail_Toshiba.jpg">
<IMAGES>
<IMAGE>email_Toshiba(1).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="enews" client="Vignette"
buttonIMAGE="enews_Vignette.jpg">
<IMAGES>
<IMAGE>enews_Vignette(1).jpg</IMAGE>
</IMAGES>
</BUTTON>
<BUTTON title="banner ads" client="Winding Road"
buttonIMAGE="banners_Windingroad.jpg">
<IMAGES>
<IMAGE>banners_Windingroad(1).jpg</IMAGE>
<IMAGE>banners_Windingroad(2).jpg</IMAGE>
<IMAGE>banners_Windingroad(3).jpg</IMAGE>
<IMAGE>banners_Windingroad(4).jpg</IMAGE>
</IMAGES>
</BUTTON>
</INTERACTIVE>
------------------------------------------------------------------
THIS IS MY CODE:
//hide the flash menu until the XML loads
_parent._visible = false;
// xml processing
menu_interactive_xml = new XML();
menu_interactive_xml.load("xml/interactive.xml");
menu_interactive_xml.ignoreWhite = 1;
//
menu_interactive_xml.onLoad = function(ok) {
// create main menu after successful loading of XML
if (ok) {
this._parent._parent.loading._alpha = 0;
create_menu();
} else {
trace(menu_interactive_xml.getBytesLoaded());
}
};
//
counter = 0;
function create_menu() {
while (counter<menu_interactive_xml.firstChild.childNodes.length) {
attachMovie("global_button", "btn"+counter, counter+1);
//place the buttons
set("btn"+counter+"._x", counter*97-97);
row = 1;
if(counter>3){
row = 2;
set("btn"+counter+"._y", btn1._y + 82);
set("btn"+counter+"._x", counter*97-485);
}
if(counter>7){
row = 3;
set("btn"+counter+"._y", btn1._y + 164);
set("btn"+counter+"._x", counter*97-873);
}
if(counter>11){
row = 4;
set("btn"+counter+"._y", btn1._y + 246);
set("btn"+counter+"._x", counter*97-1261);
}
if(counter>15){
row = 5;
set("btn"+counter+"._y", btn1._y + 328);
set("btn"+counter+"._x", counter*97-1649);
}
set("btn"+counter+".row", row);
set("btn"+counter+".column", counter+1-((row-1)*4));
btn1._x = 0;
// set the button's text
set("btn"+counter+".the_title",
menu_interactive_xml.firstChild.childNodes[counter].attributes.title);
set("btn"+counter+".the_client",
menu_interactive_xml.firstChild.childNodes[counter].attributes.client);
//set("btn"+counter+".image0",
menu_interactive_xml.firstChild.childNodes[counter].firstChild.childNodes);
//trace(btn1.image);
imgcounter = 0;
set("btn"+counter+".totalImages",
menu_interactive_xml.firstChild.childNodes[counter].firstChild.childNodes.le
ngth);
totalImages =
menu_interactive_xml.firstChild.childNodes[counter].firstChild.childNodes.le
ngth;
//trace(totalImages);
//trace(imgcounter);
while (imgcounter<=totalImages) {
set("btn"+counter+".image"+imgcounter,
menu_interactive_xml.firstChild.childNodes[counter].firstChild.childNodes[im
gcounter].childNodes);
imgcounter++;
}
//set("btn"+counter+".btnNum", counter);
// load the button image
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.loadClip("images/interactive/thumbs/"+menu_interactive_xml.firstChi
ld.childNodes[counter].attributes.buttonIMAGE,
this["btn"+counter].imageLoader.btnImage);
counter++;
}
_parent._visible = true;
info_clip._visible = false;
}
------------------------------------------------------------------
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Britton
Sent: Thursday, May 25, 2006 10:18 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] XML Parsing
How many nodes are in the XML file?
Can you post the code that does the parsing?
Mike
_______________________________________________
[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