# XML DOC from an Array

**URL:** https://forum.kirupa.com/t/xml-doc-from-an-array/102201
**Category:** Uncategorized
**Created:** [February 20, 2004, 8:43pm UTC](https://forum.kirupa.com/t/xml-doc-from-an-array/102201 "2004-02-20T20:43:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![scot](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@scot](https://forum.kirupa.com/u/scot)
#### Post date: [February 20, 2004, 8:43pm UTC](https://forum.kirupa.com/t/xml-doc-from-an-array/102201/1 "2004-02-20T20:43:19Z")

</div>

how can I create a XML docuement in ActionScript that looks like this

\<obj\>1st post  
\<obj\>reply to 1st\</obj\>  
\</obj\>  
\<obj\>2nd post\</obj\>  
\<obj\>3rd post  
\<obj\>reply to 3rd  
\<obj\>reply to 2nd of 3rd post\</obj\>  
\</obj\>  
\</obj\>  
\<obj\>4th post\</obj\>

from this array of data…

```auto

core = new Array();
core[0] = new Array(4);
core[0][0] = 1;
core[0][1] = 0;
core[0][2] = 1;
core[0][3] = "1st post";
core[1] = new Array(4);
core[1][0] = 2;
core[1][1] = 0;
core[1][2] = 2;
core[1][3] = "2nd post";
core[2] = new Array(4);
core[2][0] = 3;
core[2][1] = 0;
core[2][2] = 2;
core[2][3] = "3rd post";
core[3] = new Array(4);
core[3][0] = 4;
core[3][1] = 0;
core[3][2] = 2;
core[3][3] = "4th post";
core[4] = new Array(4);
core[4][0] = 5;
core[4][1] = 1;
core[4][2] = 1;
core[4][3] = "REPLY TO 1ST POST";
core[5] = new Array(4);
core[5][0] = 6;
core[5][1] = 3;
core[5][2] = 2;
core[5][3] = "REPLY TO 3RD POST";
core[6] = new Array(4);
core[6][0] = 7;
core[6][1] = 6;
core[6][2] = 2;
core[6][3] = "REPLY TO 2ND OF 3RD POST";

```

kind of at a lost trying to figure all the if() – for() etc… out

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 20, 2004, 10:03pm UTC](https://forum.kirupa.com/t/xml-doc-from-an-array/102201/2 "2004-02-20T22:03:49Z")

</div>

I would use a recursive function that basically builds a tree data structure (that reflects the heirarchy of the threads) and then traverse the tree to output the XML.

However, before I give you an example, I need to understand if the numbers in your array are significant in understanding the thread structure, or if you are solely going off the words (that would be a pain). At the moment, I can’t figure out the significance of the 2nd and 3rd numbers stored with each message.

It _seems_ like the first number is the post number, and the second number is the “reply\_to” number and the third number is maybe the “reply\_to\_sub” number, but if that’s the case, you made some mistakes in your data entry…

- Jim

PS. Although I love Flash, it wouldn’t be my first choice for implementing a messaging system…
