Hi all...

I've spent the last few days trying to decide the best way to store data (i.e. save to file) for a web app I'm currently building.

At the moment I'm storing HTML content in plain text files. But now I need to store additional information in relation to these files. E.g. title, description, and other 'meta' data. I will also later need to store other bits of information. The amount of information varies i.e. it's not set config variables I'm defining. There are some occasions when I will need to access all this meta data at once e.g. a list of all the titles.

I've thought of using mySQL, but want that app to be as easy as possible to setup. Editing the data by hand (text editor) would also be nice.

Thus I thought XML would be perfect method for storing this data. I've no problem reading data with the PHP parser functions but it seems to be a mission writting XML back to files (I want to do it with as few lines of code as possible, and have reasonable performance). (A small function to write specific nodes back to an XML file would be almost perfect?). The PHP Dom component is not currently setup on most hosts which is why I'm hesitent in using this approach; and it is supposidly slower. Other than this I would think this would be almost perfect as it can easily write back to a file.

I've also looked at PhpdocXMLReader + PhpdocXMLWriter and XML22 (http://code.ister.org). But these really just seem to be functions that emulate the Dom, without actually using the Dom...

The other issue I've come up with is the matter of size of the XML files. What size should an XML file be, in regards to performance? Currently I'm guessing my main data file will be around 50K on average, but my be anywhrere between 25K and 300K. How does this affect performance (and depending on which method?). Most of this data is actual HTML content which I suppose I could keep out of the XML file and store in seperate txt files. Would this be a better approach?

Any comments/thoughts/feedback welcome.
I'm getting really frustrated with the functionality of PHP, in this regard - and there must be people out there with the same problem?


    Couldn't you just print lines of XML just like normal HTML?

    Or do you mean that you want to edit existing files without having to read the whole file in and then write it all back out?

      Yeah it's editing existing files... Which makes it a pain. What's the easiest most efficient method of updating these files. It would be fine reading the whole file and then find/replace content, then write back to file. But there must be a better way?

        XML File is good choice for this job.

          a month later

          Can anyone give me a proper response????

            Write a Reply...