开发者

Can XML be used to store, modify and retrieve data in PHP like it can with MySQL? Managing data for general-purpose storage (eg. CRUD, CMS)

This is a long and old question that doesn't get to the point. I basically wanted to know practices involving flat files and the extent they could be used, as a replacement for SQL, mostly in terms of multi-user capability.

At the time, I was wanting to replicate a SQL table editor interface with flat files, allowing collaborative editing. Basically like a multiuser Excel, with an automated data-entry interface, and interactive sortable tables. I also wanted to build a CMS index page for a server, which parsed text files in order to construct a dynamic webpage, which allowed for easy updating/managing.

I've been beginning to learn MySQL, and XML. For dynamic data storage, I prefer XML over MySQL because it doesn't require a server and can be edited within a text-editor, but I'm unsure whether they can be used for similar things.

(I know that MySQL and XML are two completely different things, but I'm looking at this in regards to data storage.)

In the past I've manually stored lists of stuff in *.txt files (to keep track of things), sometimes with multiple fields per-row kinda thing, like a table, or lines with related data. HTML tables are good for this, but it would be even nicer to be able to edit directly in the page without the need for a text editor, and in certain situations, allow multiple persons (collaborative editing) to edit different sections at the same time.

(I want to use PHP to create scripts that can do this - allow editing of files in browser, including collaborative. I want to learn data manipulation methods in general.)

So basically, I want to create an index for whatever scripts and documents I'd want to display, in the form of a Content Management System. I'd want pages to be modular somehow.. Some modules would be a CRUD (create, read, update, delete) with tabular data, another module could be a pastebin-like text dump derived from a PHP script, some sort of article-publishing system for wiki-like linked articles, single articles or blog posts.

Anyway, I've made scripts that parse XML files, and I like the idea of separating content from presentation, but I don't know how/if XML could be incorporated into a CMS (or any dynamically-editable situation), as most popular ones use MySQL. This is only for personal use and not for some big site, and it would be nice for it to be simple and portable, only requiring the Web server. I'd only prefer MySQL开发者_JAVA百科 as a last resort, as I don't like having to setup MySQL every time I switch servers, or going through MySQL connection errors.

What should I do / Any suggestions?


I prefer XML over MySQL because it doesn't require a server

I prefer to travel on foot rather on wheels because it doesn't require a car. So, I spend 6 hours to get to my job and back every day.

XML can be edited within a text-editor

In theory.
In practice, XML is bound with such a number of strict rules and standards that you scarcely can edit a comma without breaking the whole file.
Face the truth - it is for programs, not humans.

In the past I've manually stored lists of stuff in *.txt files

You'd better stick with this approach further

HTML tables are good for this,

HTML tables are worse for this, even worse than XML.

I want to create an index for whatever scripts and documents I'd want to display, in the form of a Content Management System.

You are taking Content Management Systems wrong. It's Content Management System, not scripts management system. It merely manages the content, the data stored somewhere.

I like the idea of separating content from presentation,

I like it too, but your XML has nothing to do with this idea.

What should I do / Any suggestions?

Learn to drive a car. Do not remain a pedestrian.
Learn databases.

An interesting reading http://www.joelonsoftware.com/articles/fog0000000319.html


So you have two questions: "Can XML be used like MySQL?" (No, it must be treated different, use XPath instead of SQL etc.) and "Can XML be used for building a CMS?" (Yes, there are some like that, e.g. GetSimple CMS - see http://get-simple.info/start/) You must be aware that XML is suitable only for smaller amounts of data, but in that case you probably don't need the weight of a database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜