Suggestions on implementing a xml Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashipj
Forum Newbie
Posts: 1
Joined: Sat Dec 05, 2009 3:46 am

Suggestions on implementing a xml Database

Post by ashipj »

Hi guys,
Am trying to make a xml file, to act as a small database. It will have a structure as given below.

Code: Select all

 
<?xml version="1.0" encoding="ISO-8859-1"?>
<db_name>
    <tbl_video>
        <video_id>"001"</video_id>
        <file_name>"sample.wmv"</file_name>
    </tbl_video>
    <tbl_video>
        <video_id>"002"</video_id>
        <file_name>"sample.mov"</file_name>
    </tbl_video>
</db_name>
 
I need to
1.) read from the from existing entries (select statement with where clause) and print out data.
2.) write to existing xml file (Insert statement)
3.) Update xml (Update statement)
3.) Save xml file

I shall handle logic behind SQL statements, but i need suggestion to start, as i am unfamiliar with PHP XML libraries. I have gone through most of the libraries (SImpleXML,DOM, XMLParser, XMLreader, XMLwriter) but none of them alone seems to have all features which i need.

Could anyone advise me on how to implement this.

Thanks and Regards
ashipj
AlanG
Forum Contributor
Posts: 136
Joined: Wed Jun 10, 2009 1:03 am

Re: Suggestions on implementing a xml Database

Post by AlanG »

As XML is extensible; adding, updating and removing various elements is a piece of cake. You want to use SQL to do this for you. Here's the problem. You will have to parse and translate queries yourself, which is essentially re-inventing the wheel. Lucky for you, the problem is already solved. :)

There are 2 main types of XML databases. Native and xml-enabled. Native databases are designed to handle XML documents and use their own query language (usually XQuery or XPath). XML-enabled databases generally just hide the entity-relationship model behind a nice XML front.

Here's a nice article to get you started: http://www.kitebird.com/articles/mysql-xml.html
Post Reply