I want to modify my xml file in PHP based on the following criteria.
my xml structure look like this:
<?xml version="1.0" encoding="ISO-8859-1" ?> <markers> <marker> <type></type> <title></title> <address></address> <latitude></latitude> <longitude></longitude> <marker> <marker> <type></type> <title></title> <address></address> <latitude></latitude> <longitude></longitude> <marker> </markers>
Now every time when xml going to modify, with the type attribute.
means, on first time search string == "hotels" then data related to hotels will be stored in xml file as above format.
Now when again search for hotels is done then it will remove the elements which have child element with value hotels.
and search for different query for e.g. schools is done at that time data related to the schools are appended to the xml file. with the data of the hotels.
now again search for schools is done then it will remove the element related to schools.
Thanks in advance.
You can use the DOMDocument from PHP.
You load your file and than loop trough the childNodes of the document.
You can save your output XML like this
You can include the library directly from Google Code Repository.
The library is cross-browser and very small. It should be cached in many cases, because some sites use it from Google Code