PDA

View Full Version : Popularing a form from XML



jonshutt
23 Nov 2009, 10:13 PM
Hi folks

I'm reworking an existing website, and there are a series of web forms, surveying the client. The data from each form is saved in mpsql fields, and its actually saved as XML format, so that each form field becomes an xml element, and the value that was entered becomes the content of the xml tag - eg <inputBox1>my entry</inputBox1>

When I'm looking for, is a simple (as simple as possible!) javascript or ajax system that I can use to read the xml content out of the database, and populate the form on the page with the right values

Then, i'm also looking for again for an ajax feature to save the content back to the xml format, and into the database.


There is already a system in place, but it seems very complicated, and also uses some custom php classes - I want to avoid using these so that the system can run on hosts that don't have the costum php classes installed.

Hope this makes sense

Jon

Alan
25 Nov 2009, 04:16 PM
Saved as MPSQL? Do you mean MySQL or are you actually referring to MPSQL (a gui interface for PostgreSQL)?

Ok, I'm going to assume you meant MySQL (as you meantioned fields)? How are they stored in the database? Has it been xml enabled? If so... then it makes sense. :)

So what you will need to do is fetch the result set (which will be in an XML document format) and then parse it. You can use the SimpleXML (http://www.php.net/manual/en/book.simplexml.php) extension to easily parse it.