ldoozer Posted May 14, 2007 Share Posted May 14, 2007 Hi all, I am working on a google maps project and wondered if it is possible to add map points to my xml file that is called in. here's an example of the xml: <markers> <marker lat="43.65654" lng="-79.90138" html="Some stuff to display in the<br>First Info Window" label="Marker One" /> <marker lat="43.91892" lng="-78.89231" html="Some stuff to display in the<br>Second Info Window" label="Marker Two" /> <marker lat="43.82589" lng="-79.10040" html="Some stuff to display in the<br>Third Info Window" label="Marker Three" /> </markers> I would like to be able to create a php form that allows users to add more point or delete old ones. If any one could give me some help or point me in the direction of some examples i would be gratefull. Thanks Steve Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/ Share on other sites More sharing options...
per1os Posted May 14, 2007 Share Posted May 14, 2007 How are you planning on storing the data? Flat file or DB. Flat file will be tougher but doable, I would recommend a DB. Either way do you have starting code at all? If so that would be nice to post. Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/#findComment-252962 Share on other sites More sharing options...
Barand Posted May 14, 2007 Share Posted May 14, 2007 If you are using PHP5, look at simplexml functions Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/#findComment-252964 Share on other sites More sharing options...
ldoozer Posted May 14, 2007 Author Share Posted May 14, 2007 I am using PHP version 4.3.10, unfortunatly. The xml is stored in xml files on the server so I would be looking to open and change or add to them thorugh php. Not got any starting code yet, cos I have no idea really where to start - sorry Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/#findComment-252969 Share on other sites More sharing options...
per1os Posted May 15, 2007 Share Posted May 15, 2007 Since you havn't started I would suggest storing the files in the DB, if it were me. Anyhow to get you started you need to look into the file functions. www.php.net/file_get_contents for the initial contents below are required for writing to a file www.php.net/fopen www.php.net/fwrite www.php.net/fclose Through those you will want to read the current xml file into a string (can also be done into an array with www.php.net/file) once that is done you will want to manipulate the string or array to include the new lines you want in the file by using something like strstr to find a certain position in a file or even str_replace may help if you know a closing tag to an element and just replace the closing tag with the closing tag + new data. After that write it back to the file and there you go =) Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/#findComment-253212 Share on other sites More sharing options...
ldoozer Posted May 15, 2007 Author Share Posted May 15, 2007 Thanks very much for all that. Quote Link to comment https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/#findComment-253858 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.