i want some help to Delete one or more record from xml using php script. it should load the xml file and delete the record and save again as xml.
i want some help to Delete one or more record from xml using php script. it should load the xml file and delete the record and save again as xml.
You can do that with these 3 functions. You may need to run the preg_replace a few times or add in some other matching depending on what you are replacing.
file_get_contents
http://php.net/manual/en/function.file-get-contents.php
preg_replace
http://php.net/manual/en/function.preg-replace.php
file_put_contents
http://php.net/manual/en/function.file-put-contents.php
Corrections to my coding/thoughts welcome.
XML is useful to store information, but once you need to delete or change it, the process becomes much more complex. I recommend thinking about using a database. It will be harder to setup but easier to use for complex operations like this. It is possible to do this with XML, but it is harder and you might save time if you need to do this sort of thing frequently.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
mtazam123 (08-25-2010)
If you're set on XML, the easiest way I've found is using simpleXML. To remove entries, you need to useunset()on the node in question.
As djr said, however, it is a very slow and inefficient method compared to a database.
thanks man
but my requirment is to do with the xml
Did one of the answers about XML solve the problem, or do you have another question?
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks