Php performs a simple addition, deletion, modification, and query (CRUD) operation on xml, assuming the following xml file exists:
Setting1 value
Setting2 value
Setting3 value
............
How to use php to perform CRUD on it? In fact, it is better to use SimpleXMl for such simple xml files. You can operate on it like this:
// CREATE $ config = new SimpleXmlElement ('
'); $ Config-> setting1 = 'setting1 value'; $ config-> saveXML ('config. XML'); // READ $ config = new SimpleXmlElement ('config. xml '); echo $ config-> setting1; echo $ config-> asXml (); // UPDATE $ config-> setting1 = 'New Value '; $ config-> setting2 = 'setting2 value'; echo $ config-> asXml (); // DELETEunset ($ config-> setting1); $ config-> setting2 = NULL; echo $ config-> asXML (); unlink ('config. XML ');
For more details, go to the official PHP usage examples and API description.