Link to home
Start Free TrialLog in
Avatar of dban00b
dban00b

asked on

Flash XML variable appending or combining

Say I have the following XML output

<?xml version="1.0"?>
<root>
      <chat>
            <message id="14518">
                  <date>2007-10-06 17:26:33</date>
                  <from>Anonymous</from>
                  <to>ALL</to>
                  <text>test message</text>
            </message>
      </chat>
</root>

And I load it up into my Flash variable chatXML:XML;
Which works fine, Now a new message has been added to the chatrrom

<?xml version="1.0"?>
<root>
      <chat>
            <message id="14519">
                  <date>2007-10-06 17:27:48</date>
                  <from>Anonymous</from>
                  <to>ALL</to>
                  <text>New Message at 5:27 test</text>
            </message>
      </chat>
</root>

Presently I can reload my chatXML variable with the new outpput and add the new message to the display.
Is there a way I can combine the two XML outputs into one variable to retain the old information?  And also rather than making my XML output produce all messages each go for a lot of wasted redundancy.

I'm thinking that maybe I could do something like use a new var tempXML and somehow use
newID= tempXML.chat.message.@id
to add
tempXML.chat.message.(@id==newID) to chatXML.chat

Thanks for the help!!
ASKER CERTIFIED SOLUTION
Avatar of tomaugerdotcom
tomaugerdotcom
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dban00b
dban00b

ASKER

Each call to the XML output only gives what is new since the last call.
The appendChild() function worked exactly like I wanted, it even worked in a for-each loop to append all the messages found in tempXML to chatXML

Thanks!!!