php and xml

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
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

php and xml

Post by Vegan »

I have been considering XML more lately as a solution to several ideas that have come to mind

the open graph stuff used by facebook etc want more tags than ever

so I noticed a function to load an XML to a PHP array and I assume I can then write it back with revisions, this would make do as a database

the hard part is figuring out how to conjure up more meta tags for SEO etc etc etc etc etc
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php and xml

Post by requinix »

XML is just a container for data. It doesn't actually do anything. You could store your Open Graph data in anything: PHP code, INI file, XML, database, YAML...
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: php and xml

Post by Vegan »

I was considering using XML as a container for site content, more or less as a database but using XML instead of SQL etc

eventually I was pondering the whole site being carved up into XML and PHP etc
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php and xml

Post by requinix »

XML is nice and all, useful for static configuration like database credentials and such, but a database is better in general. Searching through XML is horrible compared to what you can do with a database.

But don't let me stop you. Go ahead and try it out for yourself, learn what it can do and what it can't do. I did that myself once a few years ago: the website was designed with XML and rendered into HTML using XSLT (on the client no less), and it was cool. But it isn't the kind of thing I would do "for real".
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: php and xml

Post by Vegan »

Much of the content on many sites including mine is pretty static so XML seems to be as good as anything.

I can use run of the mill forms to insert into the database etc

I was thinking that I have Excel which can save as XML so why not use that as a datasource

then PHP can select what it needs to achieve a given page
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php and xml

Post by requinix »

Go ahead and try it. You'll learn stuff along the way. I mean, it's not like this is taboo or anything, it's just not necessarily the "best way" (whatever that may be) to do things.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: php and xml

Post by Vegan »

I was thinking that XML is best suited to smaller chunks of data, rather than something with 10,000 objects
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php and xml

Post by requinix »

At the very least it would take a chunk of memory to load the whole thing into PHP at once. So maybe XML isn't the best choice after all...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php and xml

Post by Christopher »

Vegan wrote:so I noticed a function to load an XML to a PHP array and I assume I can then write it back with revisions, this would make do as a database
XML files make a terrible database. XML is a reasonable way to store source documents. XML is reasonable for passing small data sets. JSON is probably preferable for most things these days that used to be done with XML.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: php and xml

Post by Vegan »

I was looking at managing advertisements which are not that diverse, and they are becoming more keyword based instead of specific items

The idea of XML is simply a container for keywords which I can modify with a spreadsheet when new marketing ideas come along

Other content would be best in a conventional database
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php and xml

Post by requinix »

That will involve searching. Even if just for single keywords, it's searching.

You should use a database.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php and xml

Post by Christopher »

Vegan wrote:The idea of XML is simply a container for keywords which I can modify with a spreadsheet when new marketing ideas come along

Other content would be best in a conventional database
If you have it in a spreadsheet, just export as tab delimited and use LOAD DATA to quickly import it into that keywords table.
(#10850)
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: php and xml

Post by Vegan »

seems to be a lot of ideas for data i have not considered, one loaded into PHP arrays its easy for functions to do whatever

i like the idea of using an independent data source
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply