PDA

View Full Version : editing part of an xml file, not all


frankenscarf
08-17-2004, 07:48 AM
so i've got this nice xml file that contains dozens of childnodes. each childnode has a dozen attributes.

i can pull the attributes out of a specific childnode and populate textfields with them. now i want to edit one or more of those textfields and save changes to original xml file.

assuming that i can pass both the originalNode and modifiedNode data from Flash, using php, how can i replace a specific childnode in the xml file with an updated version of itself? all i've read about thusfar has been writing new files or overwriting the whole, not editing individual parts.

any help is greatly appreciated.

senocular
08-17-2004, 11:46 AM
its just a lot easier and often faster to replace the whole xml file with the new version instead of going through and editing and resaving. So... you might want to do that.

frankenscarf
08-17-2004, 09:48 PM
thank you for the reply senocular.

based on what i've learned, that looks like it's the best solution.

my next step will be creating updatedXML based on originalXML and making sure that originalXML has had the node in question replaced with the updated node.

i'll post results/problems as they occur.
thanks again. :D

frankenscarf
08-18-2004, 08:30 AM
okay then. i can write changes to my xml file. yay me.

new problem. when i go to view the changes, i.e. call the function that reads and displays the xml data, the changes don't show. it's as if it's still working with the original file. if i close and reopen the app, it reads the new data fine.

my function loads the xml file whenever it's called, is there something i can add to make sure it gets the latest version of said file?

is this a problem i'm only encountering because i'm running the test server on my machine?

little help? ;)

::edit:: i've found something that sounds like it solves my problem, but i don't know how to implement it. (see here: http://tupps.com/flash/faq/xml.html#4-G )

i'm sure i can learn to write a random num generator, but how do i append it to the myfile.xml, is this even close:
my_xml.load('calendar.xml?myrandom');
because it didn't work when i tried it.

please help