PDA

View Full Version : Parse XML field?


mr breaker
05-06-2004, 11:08 AM
I have a simple xml file:


<item>
<date>4.22</date>
<news>text here</news>
</item>


How can I parse out the date and text so I can put them in a text box?

dangerouspuppy
05-10-2004, 05:53 AM
try this one:
http://www.kirupa.com/developer/actionscript/xmltofromflash.htm

Scottae
05-10-2004, 05:25 PM
// create xml object
my_xml = new XML("<item><date>4.22</date><news>text here</news></item>");

// create text field
this.createTextField("my_txt", 0, 0, 0, 100, 0);
with (my_txt) {
autoSize = true;
border = true;
}

// loop through xml object and stick the nodes into the text field
for (var i = 0; i < my_xml.firstChild.childNodes.length; i++) {
my_txt.text += my_xml.firstChild.childNodes[i].firstChild + "\r";
}