Advertisement

03.18.2008 at 08:44AM PDT, ID: 23250590 | Points: 500
[x]
Attachment Details

Loading XML Into Flash, Writing Better Code

Asked by rgarimella in Macromedia Flash

Hi Folks,

I am loading an XML document. Please see the flash file and look for the function processmaincontent(xmlDoc_xml)

How do I write better code than the one below so that I dont have to use the NextSibling procedure.

I was wondering if For Loops would be better and need help with that

thanks

RG

Flash File AS2.0

http://www.4shared.com/file/41166354/6aec70e7/contentloader_EE.html

XML File

http://www.4shared.com/file/41165668/5c09020a/content.htmlStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
for (var n = 0; n<xmlDoc_xml.firstChild.childNodes.length; n++) {
                if (xmlDoc_xml.firstChild.childNodes[n].nodeName == "getcontent") {
	                    maincontent.sbnumber.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.firstChild.nodeValue);
						maincontent.coursename.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.childNodes);
						maincontent.format.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.childNodes);
						maincontent.template.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes);
						maincontent.textContent.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes);
						maincontent.userInstruction.push(xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes);
						maincontent.mediaElement.push({mediaLink:xmlDoc_xml.firstChild.childNodes[n].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.attributes.mediaLink});
            	} else {
                        maincontent[xmlDoc_xml.firstChild.childNodes[n].nodeName] = xmlDoc_xml.firstChild.childNodes[n].firstChild.nodeValue;
                }
        }
[+][-]03.18.2008 at 11:57PM PDT, ID: 21159006

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 08:24AM PDT, ID: 21162470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080924-EE-VQP-39 / EE_QW_2_20070628