Trouble getting XML data to display

Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default Trouble getting XML data to display

    I'm having a slight problem getting XML data to read out in dynamic text files.
    I'm doing a pretty small experiment here. The XML file loads fine. I just must
    be making some small error in how I assign the value of the text fields to the
    values in the XML file. Can anyone please tell me my error? I am using Flash
    CS3 and ActionScript 3.

    I have a simple XML file:
    <?xml version="1.0" encoding="utf-8"?>
    <primary>
    <state>Montana</state>
    <race_type>primary</race_type>
    </primary>

    In my .fla, I have a dynamic text field with an instance name of State_name. I
    have another dynamic text field with an instance name of Type_race.

    Then, in my .fla, I have this code:

    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.TEXT;
    loader.addEventListener(Event.COMPLETE, onLoadXML);
    loader.load(new URLRequest("dems.xml"));
    function onLoadXML(ev:Event) {
    try {
    var myXML:XML = new XML(ev.target.data);
    var list:XMLList = myXML.primary;

    State_name.text = list.state;
    Type_race.text = list.race_type;

    }
    catch (e:TypeError) {
    trace("Could not parse the XML");
    trace(e.message);
    }
    }
    stop();


    Laura MS Guest

  2. Similar Questions and Discussions

    1. display data points but not data tips
      does anyone know how to display the data point, but not the data tip? i just want to display the circular node that shows where the data point is,...
    2. How to display a set of data in a data grid when drivenby a combo box?
      I am trying to build a page where the user can select a syle of food (i.e. chinese, italian etc) from a combo. I would then want the relevent...
    3. Trouble inserting data in database
      I use DW 2004, XP with sp2, and Access 2003. Im planning to make a site that is possible to log in and update news from the web. So I have made a...
    4. Data::Dumper trouble
      Hi all, I want to store some complex data. My first solution made use of Storable, which worked just fine. Now I learned that neither Storable nor...
    5. Display data from database in a scrollable data grid on an ASP Page
      Hi All, I want to display data from database in a scrollable data grid on an ASP Page. I want to use it for entering data also. Should i have to...
  3. #2

    Default Re: Trouble getting XML data to display

    Hi

    Have you tried to trace(list.state) and trace(list.race_type) if they return
    undefined then your variable references are wrong.

    If this is OK and you get correct node data, then try embeding a font on your
    dynamic textboxes.
    You never know, strange things can happen.

    Hope it helps

    The Feldkircher Guest

  4. #3

    Default Re: Trouble getting XML data to display

    Hi,

    I dispensed with the list altogether and just used the XML object:

    var myXML:XML = new XML(ev.target.data);

    Then I refer to nodes in the XML like this:
    myXML.statename[i]

    I'll keep working on this so that I can iterate through the nodes in my XML
    file without having to state them by name, but this syntax is working. Thanks!

    Laura MS Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139