Click to See Complete Forum and Search --> : XML + Webshop
Danii
November 24th, 2004, 08:23 AM
Hi!
I've heard that xml is good and that I should use it. But what should I use xml for? What can I do with xml?
I'm going to make a webshop in php. How can I use xml here? What should be saved in a database (MySQL) and what should be saved in a xml document?
As you can see I'm really new on this. I want to know what to use xml for. How to use it, etc etc.
How do I use php with xml?
Please give me some examples.
Thanx in advance.
khp
November 24th, 2004, 12:56 PM
I've heard that xml is good and that I should use it. But what should I use xml for? What can I do with xml?
Well the primary purpose of XML is to store data in a, presentation and context independent manner. The situation where XML is most usefull, is when you need to display the same data in multiple formats.
I'm going to make a webshop in php. How can I use xml here? What should be saved in a database (MySQL) and what should be saved in a xml document?
With a WebShop, both XML and an SQL database would be good candidates for storing product information. Basic information like height, weight, warrenty, And a host of other device specific data could be stored either in an SQL table, containing a field for each type of information. Or in XML files perhaps looking something like this
<product id="0001" name="Troll">
<description>A live troll</description>
<height inches="35" cm="100"/>
<weight lbs="50" kg="25"/>
<warrenty>3 Years</Warrenty>
<diet>Mostly chewed up little kids</diet>
...
</product>
The main drawback with an SQL table in this case, would probably be that the product table might have to hold more than a hundred fields containing all kinds of imformation, most of which are only relevant for a small subset of your products (assuming that you are selling a wide varaity of products). It's doable but perhaps not very pretty.
And if you won't be selling more than perhaps a few hundred different products, using XML files to store the data, should be quite workable.
For keeping track of all your sales, an SQL database is probably the better choice. A sales table might only contain 5-10 fields, while the number of records might grow to many many thousands over time. Few XML engines work well with large datasets.
How do I use php with xml?
There are XML libraries for PHP these are documented at http://www.php.net/manual/en/
Danii
November 25th, 2004, 06:06 AM
Thank you for the reply :)
If I'm going to add or change som info, is it easy with xml? Also if I want to delete something.
When I'm going to read from a xml file. Is it possible just to read the price only where the price is for example > 100$ ?
Thanx again.
khp
November 25th, 2004, 08:43 AM
If I'm going to add or change som info, is it easy with xml? Also if I want to delete something.
Yes, you can edit your xml files either manually using a text editor. Or you can use a highlevel interface like DOM to edit your XML files programatically. I don't have much experience with PHP's XML libraries, so I can't tell you how good PHP's support for this is.
When I'm going to read from a xml file. Is it possible just to read the price only where the price is for example > 100$ ?
Yes of course.
Danii
November 25th, 2004, 11:47 AM
Thank you khp. You clared up some questions. I'll try making the whole site in xml. It will be a challange but it's not imposible :)
Danii
November 28th, 2004, 10:35 AM
Hi again.
I have one last question. What is XSL, XSLT and RSS?
Thank you in advance :)
khp
November 28th, 2004, 01:43 PM
Hi again.
I have one last question. What is XSL, XSLT and RSS?
XSL is short for Extensible Stylesheet Language. Originally concieved to be used as a strylesheet language for creating Xml Formatting Objects pages, from arbitary XML files. But Formatting Objects never really became a popular document format. So XSLT (XSL Transformations) which can be used to transform any XML file to another XML file or a plain text file, was created as spinoff from XSL of old, now commonly reffered to as XSL-FO. These days when people talk of XSL and XSLT, they are generally talking about XSLT.
http://www.w3.org/TR/xslt
RSS (RDF Site Summary) Is a format for attaching metadata (data about data) to XML documents.
http://web.resource.org/rss/1.0/spec
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.