dynamic xml creation

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

  1. #1

    Default dynamic xml creation

    How can I make XML dynamically inside tha Flash using AS?
    Basicly i need to make structure like these one:
    <root>
    <item></item>
    ...
    <item></item>
    </root>

    That's is the code i'm using:
    var doc:XML = new XML("<root></root>");
    var item:XMLNode = doc.createElement("item");
    doc.firstChild.appendChild(item);
    trace(doc);
    ------------
    output:
    <root><item /></root>
    ------------

    And now the question, how can i add as many as i need item nodes?
    please help me, i can't get over it!

    mixey18 Guest

  2. Similar Questions and Discussions

    1. Dynamic DataGridRow creation
      Dear all, I am working with a datagrid populated by an XML via a WebService and I would like to populate my dataGrid dynamicaly (as I browse the...
    2. dynamic tag creation
      Looking for a way to dynamically evaluate a tag from a string. eg: <cfset tmp = '<cfset myRslt = "Hello">'> <cfoutput> #tmp# </cfoutput> ...
    3. Dynamic content creation
      I'm rather a newbie to flex, at the stage of considering it it is worth my time to get to know to it (or maybe laszlo...). I have this question:...
    4. Dynamic columns creation
      Hi. I have a stored procedure that among other things returns a column with values that will be used to compose a temporary table. The number of...
    5. dynamic object creation
      If I have something like this: s="Array" How whould I get something like this: aObject=s.new In "plain" english I am asking if I have a...
  3. #2

    Default Re: dynamic xml creation

    Text nodes are optional to show something is happening.

    var doc:XML = new XML("<root></root>");
    var item:XMLNode = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 1") )
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 2") )
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 3") )
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 4") )
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 5") )
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 6") )
    doc.firstChild.appendChild(item);
    trace (doc)


    --
    Lon Hosford
    [url]www.lonhosford.com[/url]
    May many happy bits flow your way!
    "mixey18" <webforumsuser@macromedia.com> wrote in message
    news:dml3ed$d29$1@forums.macromedia.com...
    How can I make XML dynamically inside tha Flash using AS?
    Basicly i need to make structure like these one:
    <root>
    <item></item>
    ...
    <item></item>
    </root>

    That's is the code i'm using:
    var doc:XML = new XML("<root></root>");
    var item:XMLNode = doc.createElement("item");
    doc.firstChild.appendChild(item);
    trace(doc);
    ------------
    output:
    <root><item /></root>
    ------------

    And now the question, how can i add as many as i need item nodes?
    please help me, i can't get over it!


    Motion Maker Guest

  4. #3

    Default Re: dynamic xml creation

    This traces undefined for me. What am I missing?
    FlashCuriouz Guest

  5. #4

    Default Re: dynamic xml creation

    Undefined could mean that the var doc is not in scope or never assigned.

    1. I created a new Flash Movie in Flash 8. Should work in MX 2004

    2. On frame one I pasted the code
    var doc:XML = new XML("<root></root>");
    var item:XMLNode = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 1") );
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 2") );
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 3") );
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 4") );
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 5") );
    doc.firstChild.appendChild(item);
    item = doc.createElement("item");
    item.appendChild(doc.createTextNode("Item 6") );
    doc.firstChild.appendChild(item);
    trace (doc);
    3. Control->Test Movie display in output:

    <root><item>Item 1</item><item>Item 2</item><item>Item 3</item><item>Item
    4</item><item>Item 5</item><item>Item 6</item></root>


    You could also do this and get same results:

    myXml_str = "<root><item>Item 1</item><item>Item 2</item><item>Item
    3</item><item>Item 4</item><item>Item 5</item><item>Item 6</item></root>";

    var doc:XML = new XML(myXml_str);
    trace (doc);
    --
    Lon Hosford
    [url]www.lonhosford.com[/url]
    May many happy bits flow your way!
    "FlashCuriouz" <webforumsuser@macromedia.com> wrote in message
    news:dnmhpv$ktm$1@forums.macromedia.com...
    This traces undefined for me. What am I missing?


    Motion Maker 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