Advertisement

02.26.2006 at 08:09PM PST, ID: 21752567
[x]
Attachment Details

Loop Through ChildNodes and Create Array

Asked by greddin in Extensible Markup Language (XML)

Tags: loop, xml, javascript, through, childnodes

I would like to be able to create VBscript function that takes in one parameter. Maybe something like this:

createArray(id)

Given the xml sample file below if I gave the function "createArray(10507)" I would like it to build an array of all the childNode id's.

myArray = array(10511, 10512, 10513, 10514, 10515)

From an xml file like this sample:

<site id="10500" level="0" parent="" label="Home" href="javascript:nodelink(10500)">
      <section id="10501" level="1" label="Flights" href="javascript:nodelink(10501)"></section>
      <section id="10502" level="1" label="Hotels" href="javascript:nodelink(10502)"></section>
      <section id="10503" level="1" label="Cars" href="javascript:nodelink(10503)"></section>
      <section id="10504" level="1" label="Crusies" href="javascript:nodelink(10504)"></section>
      <section id="10505" level="1" label="Vacations" href="javascript:nodelink(10505)"></section>
      <section id="10506" level="1" label="Specials" href="javascript:nodelink(10506)"></section>
      <section id="10507" level="1" label="About Us" href="javascript:nodelink(10507)">
            <section id="10511" level="2" label="Employment" href="javascript:nodelink(10511)"></section>
            <section id="10512" level="2" label="News &amp; Events" href="javascript:nodelink(10512)"></section>
            <section id="10513" level="2" label="Testimonials" href="javascript:nodelink(10513)"></section>
            <section id="10514" level="2" label="Specialties" href="javascript:nodelink(10514)"></section>
            <section id="10515" level="2" label="Our Locations" href="javascript:nodelink(10515)"></section>
      </section>
      <section id="10508" level="1" label="Postcards Magazine" href="javascript:nodelink(10508)"></section>
      <section id="10509" level="1" label="Contact Us" href="javascript:nodelink(10509)"></section>
      <section id="10510" level="1" label="Privacy Policy" href="javascript:nodelink(10510)"></section>
      <section id="10517" level="1" label="Travel Services" href="javascript:nodelink(10517)"></section>
</site>

Thank you for your help. I'm stuck.

Start Free Trial
[+][-]02.27.2006 at 12:07AM PST, ID: 16053457

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.

 
[+][-]02.27.2006 at 12:14AM PST, ID: 16053487

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.

 
[+][-]02.27.2006 at 06:03PM PST, ID: 16061088

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.

 
[+][-]02.28.2006 at 12:21AM PST, ID: 16062963

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.

 
[+][-]02.28.2006 at 05:43AM PST, ID: 16065014

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.

 
[+][-]02.28.2006 at 06:00AM PST, ID: 16065168

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Extensible Markup Language (XML)
Tags: loop, xml, javascript, through, childnodes
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32