Jump to content

Editting XML Files with PHP


Zipp425

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
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.