Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-20-2003, 02:24 PM   #1
fotti66
Registered User
 
Join Date: Jun 2003
Posts: 2
Default Please help XML noob

Hi everyone.
I am new to XML so like many here struggeling a bit. I know this must very easy but I cant get it to work, as I dont quite understand the naming conventions of XML yet.

I have this XML file:
Code:
<events>
	<event id='3' city='Cape Town' shortdate='22/06/2003' longdate='22 June 2003' description='hhh!' location='hhh' path='/flash/events/cpt/20030522/'>
		<eventimage thumbfilename='200361714567thumb_3.jpg' fullfilename='200361714567full_3.jpg'/>
		<eventimage thumbfilename='20036171833thumb_2.jpg' fullfilename='20036171833full_2.jpg'/>
		<eventimage thumbfilename='200361718569thumb_1.jpg' fullfilename='200361718569full_1.jpg'/>
	</event>
	<event id='9' city='Midrand' shortdate='06/07/2003' longdate='06 July 2003' description='Fish Eagle Experience' location='Expo Centre' path='/flash/events/jhb/20030706/'>
		<eventimage thumbfilename='2003617181153thumb_1.jpg' fullfilename='2003617181153full_1.jpg'/>
		<eventimage thumbfilename='2003617181210thumb_2.jpg' fullfilename='2003617181210full_2.jpg'/>
		<eventimage thumbfilename='2003617181223thumb_3.jpg' fullfilename='2003617181223full_3.jpg'/>
		<eventimage thumbfilename='20036171813333thumb_4.jpg' fullfilename='2003617183333full_4.jpg'/>
	</event>
	<event id='2' city='Cape Town' shortdate='26/06/2003' longdate='26 June 2003' description='Baxter Ball!' location='Baxter' path='/flash/events/cpt/20030525/'>
		<eventimage thumbfilename='200361718520thumb_3.jpg' fullfilename='200361718520full_3.jpg'/>
		<eventimage thumbfilename='20036171850thumb_2.jpg' fullfilename='20036171850full_2.jpg'/>
		<eventimage thumbfilename='200361718444thumb_1.jpg' fullfilename='200361718444full_1.jpg'/>
	</event>
	<event id='1' city='Durban' shortdate='25/04/2003' longdate='25 April 2003' description='City Hall goes Green!' location='City Hall' path='/flash/events/kzn/20030525/'>
		<eventimage thumbfilename='2003617181250thumb_1.jpg' fullfilename='2003617181250full_1.jpg'/>
		<eventimage thumbfilename='200361718139thumb_2.jpg' fullfilename='200361718139full_2.jpg'/>
		<eventimage thumbfilename='2003617181324thumb_3.jpg' fullfilename='2003617181324full_3.jpg'/>
	</event>
</events>
From reading through the forums I have gotten it so far to load all the event lines, but I get stuck inside the first eventimageblock of the first event line, because my loop does not work.

My ActionScript:
Code:
stop();
// create object and prepare for xml load
events_xml = new XML();
events_xml.ignoreWhite = true;
events_xml.onLoad = function(success) {
	if (success) {
		convertXML();
		nextFrame();
	} else {
		trace("error reading xml");
	}
};

//
// load in xml file
events_xml.load("events.xml");
//
// convert xml to object
function convertXML() {
	//
	_global.events_array = new Array()
	//
	mainNode = events_xml.firstChild;
	eventNodes = mainNode.childNodes;
	// read through nodes
	for (i=0; i< eventNodes.length; i++) {
		//
		if (eventNodes[i].nodeName == "event") {
			//
			events_array[i] = new Object();
			// extract events IDnumber
			events_array[i].idnumber = eventNodes[i].attributes["id"]
			// extract city
			events_array[i].city = eventNodes[i].attributes["city"]
			// extract shortdate
			events_array[i].date = eventNodes[i].attributes["shortdate"]
			// extract longdate
			events_array[i].longdate = eventNodes[i].attributes["longdate"]
			// extract description
			events_array[i].description = eventNodes[i].attributes["description"]
			// extract location
			events_array[i].location = eventNodes[i].attributes["location"]
			// extract path of images' folder
			events_array[i].path = eventNodes[i].attributes["path"]
			
			trace (events_array[i].idnumber);
			trace (events_array[i].city);
			trace (events_array[i].date);
			trace (events_array[i].longdate);
			trace (events_array[i].description);
			trace (events_array[i].location);
			trace (events_array[i].path);
			trace ("===images===")
			
//THIS IS THE PART THAT WONT WORK ARGH!
			imageNodes = mainNode.firstChild.childNodes;
			trace (eventNode[2].childNodes[1]);
			for (j=0; j< imageNodes.length; j++){
				if (imageNodes[j].nodeName == "eventimage"){
					trace (imageNodes[j].attributes["thumbfilename"]);
				}
			}
		}
	}
	// reverse order of events array so latest events are first
	events_array.reverse();
	// set initial values for main events menu
	submenu_landing_mc.startIndex = 0;
	submenu_landing_mc.totalEvents = events_array.length;
}
Please, please help, I know for a lot in here this is as easy as it can get..

Thanks for all your time and effort.
fotti66 is offline   Reply With Quote
Old 06-20-2003, 06:35 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

You might want to check this thread???
http://www.actionscript.org/forums/s...threadid=29898
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 06-23-2003, 08:49 AM   #3
fotti66
Registered User
 
Join Date: Jun 2003
Posts: 2
Default sorry just cant

get it to work

someone please help, I really, really have to finish this
fotti66 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:17 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.