Jump to content

Archived

This topic is now archived and is closed to further replies.

Zipp425

Editting XML Files with PHP

Recommended Posts

Ive been working on a way to edit an xml file, I have been using fopen and just specifying a specific line to replace, but that wasnt working very well, because sometimes lines seemed to be off, or users would give data that would cause line breaks.

I just recently learned about SimpleXML in PHP5, and I was wondering if someone could explain to me how I could use PHP to open a XML file, and select a specific tag name and replace a specific attribute, or a array of attributes.

I would be using xmlHttpRequest to pass data to the PHP file that would then open and edit the XML file.

Thanks for your help in advance

Share this post


Link to post
Share on other sites
Beautiful. Thank you very much.

Now, do you know if there is a way to make it so it will only create the new file once, and later just edit the created file?

I would like to have one standard XML file that is then editted by user select and saved to a different XML file according to their userid

IE
[code]
standard.xml
--User Changes default settings
---new attributes saved as userid.xml
----User changes more settings
-----edit attributes in userid.xml
[/code]

Nevermind, unless im wrong it looks like you can specify a file to write to with asXML()

Thanks for your help.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.