Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

actionscript wont loop xml

Posted on 2005-04-12
4
Medium Priority
?
383 Views
Last Modified: 2008-02-01
Hi,

I have some code below. generally speaking, it works, but it wont loop dislpay all text in the datagrid.

background - I load an xml file into a datagrid, when a row is clicked, a function is called and that funtion populates various text boxes etc. It also populates another datagrid, unfortunately, it only reads the first line of a particlar node, it is the correct node but it wont display the rest of the nodes.

below is a portion of the xml and i am pulling type_name and the loop is the get all 'type_name' by reading ./ext_refs/ext_ref;

<ext_refs>
      <ext_ref type_name="Secunia Advisory ID" indirect="0">13942</ext_ref>
      <ext_ref type_name="Other Advisory URL" indirect="0">http://www.idefense.com/application/poi/display?id=188&amp;type=vulnerabilities</ext_ref>
      <ext_ref type_name="Vendor URL" indirect="0">http://www.3com.com/products/en_US/detail.jsp?tab=features&amp;pathtype=purchase&amp;sku=3CRWE454G72</ext_ref>
      <ext_ref type_name="CVE ID" indirect="0">2005-0112</ext_ref>
      <ext_ref type_name="Security Tracker" indirect="0">1012958</ext_ref>
      <ext_ref type_name="ISS X-Force ID" indirect="0">18994</ext_ref>
      <ext_ref type_name="Bugtraq ID" indirect="0">12322</ext_ref>
</ext_refs>


heres the code within my highlight function which is triggered when the first datagrid is clicked;

      myDg = new Array();
      for(var i=0; i<eindex.length; i++) {
                  var typeExtRef = XPath.selectNodes(choosenEntryData[i],"./ext_refs/ext_ref")[0].attributes.type_name;
                  var typeLinkId = XPath.selectNodes(choosenEntryData[i],"./ext_refs/ext_ref")[0].firstChild.nodeValue;
                  myDg.push({Type:typeExtRef,Ref:typeLinkId});
                      }
        dgExtRef.dataProvider = myDg;
      }


note, eindex is a variable which refers to selectedItem ID in the first datagrid. (this works ok and points to the correct part of the xml file).

when I run mymovie, as I mentioned, it picks up the first type_name attributes correctly and puts it into my second datagrid dgExtRef, however, I can see that it loaded the rest into the grid but the text does not show, when you move the mouse over it, you can see the rows highlight so something is there !


any suggestions would be apreciated

cheers.
0
Comment
Question by:tmehmet
  • 2
  • 2
4 Comments
 
LVL 5

Author Comment

by:tmehmet
ID: 13767555
apologies, above has a deliberate mistake, it looks like this;

 myDg = new Array();
     for(var i=0; i<eindex.length; i++) {
               var typeExtRef = XPath.selectNodes(eindex[i],"./ext_refs/ext_ref")[0].attributes.type_name;
               var typeLinkId = XPath.selectNodes(eindex[i],"./ext_refs/ext_ref")[0].firstChild.nodeValue;
               myDg.push({Type:typeExtRef,Ref:typeLinkId});
                     }
        dgExtRef.dataProvider = myDg;
     }
0
 
LVL 27

Accepted Solution

by:
negatyve earned 2000 total points
ID: 13767999
I'm not sure I understand what you want, but maybe that's what you are trying to do:

      var myDg = new Array();
      var typeExtRef = XPath.selectNodes(eindex, "./ext_refs/ext_ref");
      for (var i = 0; i < typeExtRef.length; i++) {
            myDg.push({Type:typeExtRef[i].attributes.type_name, Ref:typeExtRef[i].firstChild.nodeValue});
      }
      dgExtRef.dataProvider = myDg;
0
 
LVL 5

Author Comment

by:tmehmet
ID: 13768092
your a genius.

one day, i'll be in a position too not know what I am doing and still make it work

:-)

0
 
LVL 27

Expert Comment

by:negatyve
ID: 13768182
:D cheers!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question