XML作为数据库 [英] XML as a database

查看:120
本文介绍了XML作为数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读关于XML,XSL,XPath等。我想在PHP中启动这个小脚本,使用XML作为数据库来创建一个简单的CRUD应用程序。我将使用SimpleXML,但阅读一些答案stackoverflow后,似乎很多人建议DOMDocument(有什么有利用使用DOMDocument比SimpleXML?)

I've been reading about XML, XSL, XPath, etc. I want to start this small script in PHP using XML as the database to create a simple CRUD app. I will be using SimpleXML but after reading some answers over stackoverflow it seems many people suggest DOMDocument (is there anything that benefits using DOMDocument more than SimpleXML?)

无论如何,什么麻烦我是如何把ID放在他们?我应该只是从1开始,然后当有人添加一个节点,增加它,依此类推?

Anyway, what bothers me is how to put an ID on them? Should I just start with "1" and then when someone adds a node, increment it and so on?

还有类别,我想要一个这样的结构。

There is also category, I want to put a have this kind of structure

Parent  
 - Children          
 - Children  
   - Subchildren  

我有一个想法,如何把它放在XML,但我的问题是解析他们。

I have an idea on how to put it in XML but the problem for me is parsing them.

无论如何,类别并没有真正打扰我。我更感兴趣,知道我是否应该保持ID计数保存在一个XML,并使用它作为参考。

Anyway, categories doesn't really bother me that much. I'm more interested to know if I should just keep an IDs counts saved in a XML and use that as "reference".

推荐答案

您说XML是数据库。 XML只是一种标记语言,你真的的意思是文件作为数据库,这将是一个错误。你会遇到并发问题,可能的损坏和一大堆其他问题,更不用说大型XML文档的糟糕性能。

You said "XML as the database." XML is just a markup language, so what you really meant was "a file as the database" and that would be a mistake. You'll run into concurrency problem, possible corruption and a ton of other problems, let alone the abysmal performance of a big XML document.

如果你需要的是一个数据库,然后只是使用:一个数据库。不是文件。

If what you need is a database, then just use that: a database. Not a file.

SQLite简单易用,并且对轻负载足够快,虽然它缺乏一个很好的对应phpMyAdmin。否则,你的webhost肯定提供了一个MySQL数据库。

SQLite is simple to use and fast enough for light loads, although it kind of lacks a good counterpart to phpMyAdmin. Otherwise, your webhost certainly offers a MySQL database.

这篇关于XML作为数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆