| 1:44 pm on Oct 7, 2002 (gmt 0)|
Have you looked here?
| 10:50 pm on Oct 7, 2002 (gmt 0)|
thanks lorax but it did not mentioned anything about inserting a data into an xml file. ... sort of appending/pre-pending the data in the xml file. Anyway, I also have a working example of using php's xpat in my site and i am doing some experiments right now.
but doing a mental experiment, i could see it worked. :)
| 1:32 pm on Oct 8, 2002 (gmt 0)|
Sorry about that copongcopong, I should have read it myself first. Interesting idea, there has to be someone here that has the answer. I'd like to know too!
| 10:07 pm on Oct 8, 2002 (gmt 0)|
Here is what i really like to accomplish. it would be sort of a cms but a very crude one. It is a flat (xml) file based, no database.
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?
| 11:50 pm on Oct 8, 2002 (gmt 0)|
anyway I find this site: [outer-court.com...] uses an php and xml file to run a forum, ... its kinda interesting but i do prefer to create a simple one for my learning process.
| 1:51 am on Oct 9, 2002 (gmt 0)|
In thinking more about this I wonder if we're making this more difficult than it needs to be. Why, for instance, couldn't you just write the form variables out using fwrite()? Build the structure of the XML doc within PHP using variables and strings and then write it all out to the drive. Am I missing something obvious?
| 2:46 am on Oct 9, 2002 (gmt 0)|
Yes that is another good idea. Could you be more specific?
Anyway, my main problem really is adding the data into the xml file and after adding the data there, it should preserve its structure.
| 1:34 pm on Oct 9, 2002 (gmt 0)|
Well, what I'm thinking is this:
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
| 12:03 am on Nov 1, 2002 (gmt 0)|
Here is a site that I have check out that uses expat to insert data to xml file:
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.