Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/51370-manipulating-an-xml-file-with-php/
Share on other sites

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.

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.