jQuery XML menu challenge

jQuery XML menu challenge

Hi All:

I have a challenging jQuery XML task I'm trying to accomplish as follows:

I have an XML structure as follows:
  1. <nav_data>
  2.       <outline>
  3.             <links>
  4.                   <slidelink slideid="_player.6LjVRsWzPla" displaytext="Scene 1" expand="true">
  5.                         <links>
  6.                               <slidelink slideid="_player.6LjVRsWzPla.6GWiXuWmXyn" displaytext="Fundamentals" expand="true" />
  7.                               <slidelink slideid="_player.6LjVRsWzPla.6gxk7XqbaT8" displaytext="Closed Captioning Example" expand="true" />
  8.                               <slidelink slideid="_player.6LjVRsWzPla.5rPNkwvz8u2" displaytext="Another Cationing Example" expand="true" />
  9.                         </links>
  10.                   </slidelink>
  11.                   <slidelink slideid="_player.5vBpwlDk0Kc" displaytext="Scene 2" expand="true">
  12.                         <links>
  13.                               <slidelink slideid="_player.5vBpwlDk0Kc.6GFHxzyjyh5" displaytext="Change in Scene" expand="true" />
  14.                               <slidelink slideid="_player.680CGwUAaSX.641pSMeVBq2" displaytext="Glossary" expand="true" />
  15.                         </links>
  16.                   </slidelink>
  17.                   <slidelink slideid="_player.680CGwUAaSX" displaytext="Menu and Resources" expand="true">
  18.                         <links>
  19.                               <slidelink slideid="_player.680CGwUAaSX.6AopJzqESlV" displaytext="Menu" expand="true" />
  20.                               <slidelink slideid="_player.680CGwUAaSX.6U6k0n98l71" displaytext="Resources" expand="true" />
  21.                         </links>
  22.                   </slidelink>
  23.             </links>
  24.       </outline>
  25. </nav_data>

My objective is to find the have each slidelink display the "displaytext" attributes and apply the slideid attributes to them.

 I'm currently able to display the 2 attributes for the first ChildNode.

 My issues are:

  1. I do not know how to create an array to display these attributes for all childNodes.
  2. I do not know how to create a relative URL for the slidelink and display the displaytext for the slidelink.

 I am not able to change the XML at all as this is produced using an courseware development IDE.

 My current scripts display the 2 items and are as follows:
  1. <script>
  2.       var loadscenelink = function(){
  3.       $.ajax({
  4.             type: "GET",
  5.             url: "story_content/frame.xml",
  6.             dataType: "xml",
  7.             success: function(xml){
  8.                   var surl = $($(xml).find('links')[0].childNodes[0].attributes["slideid"]);
  9.                   var slinkvalue = surl[0].nodeValue;
  10.                   var slinkcode = $(surl);
  11.                   console.log(surl); /* Firefox Degugging */
  12.                   console.log(slinkvalue); /* Firefox Degugging */
  13.                   var player = GetPlayer();
  14.                   player.SetVar("SceneLink",slinkvalue);
  15.             }
  16.       });
  17. };
  18. </script>
  19.  
  20. <script>
  21. var loadscenelinkname = function(){
  22.       $.ajax({
  23.             type: "GET",
  24.             url: "story_content/frame.xml",
  25.             dataType: "xml",
  26.             success: function(xml){
  27.                   var sln = $($(xml).find('links')[0].childNodes[0].attributes["displaytext"]);
  28.                   var slinkname = sln[0].nodeValue;
  29.                   var slinktitle = $(sln);
  30.                   console.log(sln); /* Firefox Degugging */
  31.                   console.log(slinkname); /* Firefox Degugging */
  32.                   var player = GetPlayer();
  33.                   player.SetVar("SceneLinkName",slinkname);
  34.             }
  35.       });
  36. };
  37. </script>

Any advise or assistance would be greatly appreciated.

Best Regards,
Dennis Hall