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?)
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
I have an idea on how to put it in XML but the problem for me is parsing them.
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”.
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 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.