Welcome to WebmasterWorld Guest from 184.108.40.206
Theoretically i know it is possible with domxl however i read that it uses a lot of server's resources and i beleive that xpat is faster.
i could imagine that it is feasible, probable, imaginable, workable, etc ... with some php coding with expat? is it or its just a pigment of my imagination? :)
<quotes>I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.
but doing a mental experiment, i could see it worked. :)
1. Create a form that would accept data. (ok)
2. Data from the form would then be inserted into an xml file. (thinking)
3. Display the xml file. (ok)
The problem that needs to be address is when inserting a data into an xml file. Here is an example.
then from the form, it would then insert another <child>data2</child>
to make the xml file,
on step 2, one idea i am thinking is to read the xml file, string replace the <?xmlhead?> and <mother> with <?xmlhead?>+<mother>+<child>data2</child> then save the xml file.
another idea i have is to use xpat to read the xml file, when it reads <mother>, it would insert the data from the form then let xpat continue reading the file, then save (or overwrite) the xml file.
am i crazy?
Form fields "mother", "child"
When the handler gets the form results we know Mother is the container for the children so we could write
$mom = "<mother><child>".$child."</child></mother>";
Right? Mind you I'm not that fluent with XML syntax yet.
And then write out the vars to an XML file using fwrite()
There are two other options I thought of. Use an XML database [xml.com...]
or if you're using a MySQL database, go ahead and insert the form data into the database and then perform a mysqldump -X to create a well formed XML document
i believe it is from a book oublished by wrox.
however, i have created my script and it is very simple and it works to insert data on the first part or on top of the xml data. it uses the stringreplace in php.
here is an example of the xml file:
the string from the form would be: <?xml version="1.0"?> <mother><child>data1</child>
then stringreplace the "<?xml version="1.0"?><mother>" on the actual xml file with the one that came from the the form. then save it.
therefore making the xml file:
sort of appending it on top or should i say pre-ppend.
then would be parse by expat.