• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Simple PHP Form ==> XML Output

masona3

Junior Member
I need a simple PHP form capable of populating an XML file with data. (I'm building a Google maps widget that maps local garage sales.)

Here's the catch, though. I need the form to kick out the XML file in exactly the following format.

<?xml version="1.0" encoding="windows-1250"?>

<markers>
<marker lat="0" lng="0" html="1234 Nowhere Street <br> Saturday, 10:00-4:00 <br> Items for sale include bed, dresser, toys for young children, and clothing." label="1234 Nowhere Street"/>
</markers>

So, basically, I need fields on the form for the following.

  • Latitude
  • Longitude
  • Address (Needs to fall under "html" value. XML break following, as seen above.)
  • Date/Time (Needs to fall under "html" value. XML break following, as seen above.)
  • Items For Sale (Needs to fall under "html" value.)
  • Label

I think it's fairly obvious based on the XML sample above where I need each piece of this content to fall. I need to be able to add entries to and delete entries from the XML file, if that's possible. If deleting entries is not possible, I at least need to be able to add entries to the XML file. I can always go in and manually delete entries or just start a new file each day. That's not a big problem.

I'd really appreciate it if anyone could help me out with this or at least point me in the right direction.
 
well


i amhavent coded php in a while, but you should look to see if there is an xml library . on win32 there is msxml, so if youw ere doing this in like asp.net you could do it easily. its possible there could be an odbc driver to an xml file, so maybe you could do something liek that too.
 
That looks like a pretty tame XML file. I don't think you would even need an XML library to create an XML document. Just use string concatenation.
 
Originally posted by: tfinch2
That looks like a pretty tame XML file. I don't think you would even need an XML library to create an XML document. Just use string concatenation.

well for just creating it it would be easy.

but he seems to want to be able to add and delete to a previous one (or maybe i did not read his post correctly)
 
You mean some php extension library. . .maybe like this.

Seriously. . .did you even try before posting? First result in google.
 
Perhaps you're going about this the wrong way. Using XML as your primary data source isn't exactly the best idea. XML is meant to be a data transmission format...an intermediate between the data source and a client application.

Is the XML format you have necessary? Are you using it with an XSLT translation to generate your Google Maps code?

For my Google Maps integrations, I've always found it easiest to use a database backend and GMapEZ. To me, this is the simplest, most elegant solution to Google Maps integration.

Not only that, but Google has an API you can use to get the longitude and lattitude from an address. You may consider using that instead. You can also use logitude and lattitude to calculate distance between sets of points...so you could do something like "Find Garage Sales within 10 Miles of My Zip Code".

Basically, either way you do this, you will need a database backend. It simply is not feasible to maintain a random access database within an XML file. The overhead is simply too much. If you absolutely MUST have that XML be output, the easiest thing to do is to generate it ad-hoc from your database table and use the header() function to change your content type to XML and point whatever translation/source to the new PHP file instead.

What you're trying to do simply isn't practical.
 
Back
Top