how do I edit xml in as3

Can someone provide me with a simple example of editing a xml-node and attribute through a input-field in as3.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

did you not come right then from your last post?
describe exact scenario of what you're doing, i'll try again to create an example.
petersegoAuthor Commented:
No, Ive been occupied with other works lately.
What I would like to see is an example of how to change the content of one node and one attribute somewhere down a complex xml-structure.
In the simple xml below lets say I want to change the attribute width to 250 and the item-node Clothes to Ships.
In reality I want to allow the user to change every node and attribute - but through a form-based interface before sending the xml back to a php-script.
<settings color='0x000000' size='9' font='arial' width='200' height='300'>

Open in new window

oh are you using php?
and where is the original xml coming from, the harddrive / server etc?
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

petersegoAuthor Commented:
its loaded from a server - the same place as the php-script.
var myXML:XML = new XML();
var XML_URL:String = "strangestore.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myxmlLoader:URLLoader = new URLLoader(myXMLURL);
myxmlLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
    myXML = XML(;
i remember fiddling with it the last time you asked and i'm sure it did work.

have a look at this link to get you started for the syntax

basically load the xml as you have, stick it in a textfield. allow the user to edit data in that textfield, and then you call i think.

petersegoAuthor Commented:
Yes, but thats what I want to avoid.
I want the user to edit the xml through a form-based interface.
Like I lined up above...
i'm not following - is my understanding of form based interface different to yours?

you have the xml sitting on the server( a physical .xml file)
you load it into flash.
display the xml inside the form which you're going to create with a save button

also I'm thinking if you're using php you don't need the FileReference you can pass the textfield data back to the php and have that update the xml file with the user's changes.
petersegoAuthor Commented:
When I say form-based I mean that each node and attribute should have its own input-field.
ah okay i don't think there's a quick way to do it.  you'll have to write the code.

you need to loop through your xml and get all the nodes and in each node check if there's attributes etc and create a textfield accordingly, and populate the textfield with that data.
then when they submit it take all the textfields.text and concatenate into one long string. parse the string as XML and then send that through to your PHP to make the file.

do you know how to work with xml in AS3? if not here's a very good resource.

i don't think it will be too difficult but it will be a lot of work.
are you building this because you need an xml editor (i know they were available for purchase in AS2 - maybe it would be worth your while to purchase one?)
petersegoAuthor Commented:
Yes, I know how to import and showing the content of  xml in as3.
Im not interested in building an entire xml-editor, but just making it possible to update the content of some xml-node or xml-attributes in an input-field where Ive placed that content - as I lined up earlier.
I kinda understand that you dont know how to do this, so if you dont mind I will close the question and start a new one, where I more clearly outline the problem from the start. :)
yeah sure, i also want to understand the problem clearly.

things you might want to explain so anybody trying to assist can understand.

1. is the xml node you want to edit going to be dynamic or is there only one specific node you want the user to be able to edit?
2. if the latter how do you want them to choose which node?
3. if the former then don't understand the problem.
4. have you got the php part working?
petersegoAuthor Commented:
Thanks, good advises. Regarding the last point, Im not absolutely sure.

I found an example of saving an internally created xml-node but I havent tried with an imported complete xml-file. (see snippet)
$filename = "readwrite/simple_edit.xml";
$raw_xml = file_get_contents("php://input");
print $raw_xml;
$fp = fopen($filename, "w");
fwrite($fp, $raw_xml);

Open in new window

this dude should be able to help you along.
near the bottom. his code does work but i'm not sure if it works in line with what you're trying to achieve in terms of "where Ive placed that content - as I lined up earlier."

good luck with it, you can close or delete this now.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.