Skip to main content
gamedev.net
🔒 Locked

[web] PHP and XML

Started by bargasteh 6 replies 1.5k views
Original Post
bargasteh
bargasteh
Hello everybody. I am trying to create a news website using PHP, MySQL and XML. I need to know your idea about my plan. it would be great if you give me your opinion about my plan. I am thinking to keep the user's acount in a MySQL database and keep the NEWS deatail in an XML file. 1. What do you thinking about the above idea ? and second question is that how can I learn about serializing my news in a XML file using PHP ? I tried to find a tutorial that show me how to serialize data in XMl but they were not very simple to understand as I am beginner. I am looking forward to hear from you.
OpenGl + C++
markr
markr
Quote:
Original post by bargasteh
1. What do you thinking about the above idea ?


Pointless, as you could store the news article in a format more helpful to your application instead. Most store each news article in columns of a table in MySQL, rather than as XML (it makes searching and extraction a lot easier).

Quote:

and second question is that how can I learn about serializing my news in a XML file using PHP ?


It depends exactly what you want to do. PHP5 has DOM functions for generating / parsing XML, as well as the SimpleXML and an older SAX-like parser.

Quote:

I tried to find a tutorial that show me how to serialize data in XMl but they were not very simple to understand as I am beginner.


I still don't think using XML is a good idea. If you're going to use the database to store your data, store each piece in a separate column (or row as appropriate) in there.

Mark
bargasteh
bargasteh
Thank you Mark for your comments and ideas about XML.

The only reason why I like to use XML is only because I want to learn how to use them in PHP (that is the only reason).

But yes you are correct I think MySql is fast and almost unlimited, but what if one day I decide to use my data in a ASP .net2 website ? Isnt XML easier to use in that regard ?

Hearing your opinion.

OpenGl + C++
Rob Loach
Rob Loach
You might want to take a look at MagpieRSS as it has the ability to translate an RSS feed (XML) into data. Another one you should look at is FeedCreator.class, which allows you to input data and then output an RSS feed.
Rob Loach [Website] [Projects] [
pash_ka
pash_ka
Quote:
what if one day I decide to use my data in a ASP .net2 website ?

I suppose, there is a way in ASP to use MySQL database. :) It is not language-specific. (Well, everything can be used improperly. You may make table with only 2 columns, one for id and another for serialized object. And if you serialize your object whith PHP's serialize() no one will help you unserialize it in ASP.)

Quote:
The only reason why I like to use XML is only because I want to learn how to use them in PHP (that is the only reason).?

You may create RSS feed from your news.
Sander
Sander
Don't use XML as a storgae language. Listen to markr. XML is a nice way to pass data between different applications but as a storage language it makes little sense. Use MySQL for that.

If you want to learn how to use XML with PHP then build a feed aggregator. That is, parse different RSS/Atom XML feeds from different sites, mix them up according to certain rules, reformat them and output it again as a website with a new RSS/Atom feed.
bargasteh
bargasteh
Thanks for your ideas, they were very useful.
I think I am going to use MySQL to store news and then I will create a RSS feed from MySQL database to learn how to use XML in PHP.

Is this what you precisely saying ?
OpenGl + C++
Sander
Sander
Something like that, yes. But go for something more challenging if you're trying to learn XML. Outputting XML is easy (that is, creating your own RSS feeds). It's the same as outputting HTML and slapping a header() in front of it to set the correct content type. Reading XML is more challenging in PHP because you have to use an XML parser of some sorts.

Try creating a website that:
1) reads RSS feeds from other (your favourite) websites
2) puts the articles from those RSS feeds in the database
3) outputs a website + RSS feed containing the articles from the database

There you have it, your basic RSS feed aggregator. Note that this is a good way to learn working with XML in PHP. Plainly showing other people's RSS feeds is probabely not the best way to create a good news site.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.