PDA

View Full Version : General Question about XML fiels with PHP



alistz
10-22-2008, 12:35 PM
Hi. I'm building a website using PHP, and I've incorporated a couple of small XML files that I read in to load my pages.

For example, I have a screen that shows a list of cities for the state you live in. The list of states and cities is read in from an XML file.

I'm trying to write some simple screens I could use, so I could hand off the task of maintaining the XML file to an admin. The screen I need would give the administrator an interface to 1. Add a City, 2. delete a City, modify a City.

I am looking for a tutorial or book that would outline or give examples of doing this. I have used simpleXML to read the file, etc. But examples of deleting nodes/adding nodes/modifying don't seem to be out there.

What is the best way to make changes to a server side XML file?

Any ideas are appreciated.

akjackson1
10-26-2008, 01:07 PM
it sounds like a MySQL database might be what your looking for, i'm not sure if it's possible to edit an XML file. Maybe some xml pros might be able to answer that questions ;)

pghcollectibles
12-17-2008, 11:25 AM
ftp access could download/upload the file within a certain directory (to limit access) where you would only keep certain files you wanted someone else to access. i would avoid the anonymous type of ftp. you can create and distribute the password/username to the admin of your choice, but remember you are still allowing them access to your server files indirectly so you should trust them.

ie: if i had ftp access to your /home/username/public_html/ftpusers/myfolder directory, i could upload a script bad.php then type in http://www.yourdomain.com/ftpusers/myfolder/bad.php and the bad thing would execute. if you could give ftp access to a folder /home/username/ftpusers/myfolder i could upload/download but not have direct url access to run a script. your file lets just say /public_html/index.php could get the xml file (or other file) the same as before:
xmlDoc.load("../ftpusers/myfolder/cities.xml");
//or
include("../ftpusers/myfolder/afile.php");
depending on what you are doing (you can access directories above the public_html folder through scripts but not directly through the browser)