[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

07/02/2007 at 01:33PM PDT, ID: 22671516 | Points: 500
[x]
Attachment Details

selecting a childNode by attribute and looping through all of it's childNodes to create an array

Asked by matzofast in Adobe Flash

Tags: array, attribute, all, childnodes, loop

selecting a childNode by attribute and looping through all of it's childNodes to create an array
Translate:
Question: Hello All,
Please help, I'm trying to select a childNode by attribute and looping through all of it's childNodes to create an array.
This is the stripped down skeleton of the XML.

So I want to build an array from the childNodes of the page with the id="extLinks"
This cannot be an absolute reference since many <page> nodes may be added and the node could be anywhere within the XML doc.

==========================
xml
==========================
<?xml version="1.0" encoding="utf-8"?>
<site>
      <tracking embed/>
      <country codes/>
      <pages>
            <page id="page1">
            </page>
            <page id="page2" >
            </page>      
            <page id="extlinks">
                  <link sLink="http://www.msn.com"/>
                  <link sLink="http://www.google.com"/>
                  <link sLink="http://www.yahoo.com"/>
            </page>
      </pages>
</site>
===============================
broken AS
This is where I am at and it is becoming a jumble.
===============================
extLinkList.onLoad = function(success) {
      //trace(extLinkList);
      var linkArray:Array = new Array();
      for (m=0; m<3; m++) {
            var sLink:String;
            var xmlNodeBase:XMLNode = extLinkList.childNodes[0].childNodes[2].childNodes;
            var xmlNodeBasePlus = xmlNodeBase.childNodes[m];
            if (xmlNodeBase.attributes.id == "extLinks") {
            xmlNodeBasePlus=xmlNodeBase.childNodes[m]
            sLink = xmlNodeBasePlus.attributes.sLink;
            linkArray.push(sLink);
            }
      }
      extLink1 = linkArray[0];
      extLink2 = linkArray[1];
      extLink3 = linkArray[2];
      trace(linkArray);
};
================================

This returns nothing, I am assuming that it is not finding anything because the if loop is never entered.

Thanks for all your input.
 
Keywords: selecting a childNode by attribute and l…
 
Loading Advertisement...
 
[+][-]07/02/07 02:27 PM, ID: 19407066

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/02/07 02:29 PM, ID: 19407070

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/02/07 03:03 PM, ID: 19407282

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 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/02/07 03:12 PM, ID: 19407339

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91