Discussion Locked

xml...why?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi,

could you give me an example of where i might use php-xml?

right now i've build lots of things using php and databases, image
libraries, content management systems, and shopping carts etc, but am
unsure where xml fits in...am i missingsomething or are there specific
applications that necessitate the use of xml?

thanks,
sanj

sanj maghera
technical architect
wiredesign

2 replies

by sparkytd

Why not? I pose that question as rhetorically as you posed yours. Do you need xml? nope.... does any application *require* xml technology? nope. XML exists for one purpose and one purpose only: to facilate the definition of data. That is it.How you apply the xml in your company is up to you. For instance, you could use it in a content management application to store your content. Or you could use it in an shopping cart application to send orders to suppliers dynamically via SOAP or some other message driven technology that conforms to their specifications. The idea is that company A declares a DTD/Schema relating to how company B can send them data. Thus any company that sends data to company A will have access to this schema,create XML files that conform to this schema, and send those.

Where I find it most useful is to use it in storing content and non-security sensitive material(if it is, then i'll encrypt the xml). It's light weight, portable, and can run on anysystem, since really, it's just a text file. As long as you can parse it, you can gain your information. As for how you use it, that is up to whether it fits into your business model...XML could replace your database if you want...XML could be your authentication model...XML could send messages to and from users/companies...XML could do anything you want it to do...i suggest reading the docs on it at www.w3c.org - they really outline the purpose and how to use it

by shelleydoll

Here are some examples from my own recent development endeavors - I'm using XML with PHP for a couple of different purposes.
- First, I developed a content management system for a fairly involved web application. I broke a lot of things out into a config file, but it kept growing and growing with things that were less and less configuration specific, and more and more content specific. I finally bit the bullet and broke everything that wasn't truly a configuration out into XML files, and parsethem into my site. That way, I only have to manage section titles, links, some content, etc., etc. from one centralized location. I really like this solution, it beats anything I had before, and is very easy to maintain. I even made a web form to create my XML files. For some instances, I use the XML file instead of my database, so I don't have to do multiple database lookups on every page just to build a nav, for example. I still store the main content in my db, but only look it up on the article page itself. I'm even able to create my XML from the database.
- Second, I started promoting my site on other places throughout the web, and found several instances where my headlines and links could be parsed by third parties if it was contained in XML. I now keep a separate XML file for other sites to parse.
- Third (this is part of a separate site, actually), I've worked out a solution with an affiliate site where we can exchange content. We've decided to use XML for this solution, so that neither of our applications has to care about what the affiliate's software does, and we don't have to allow db access. All we have to do is agree on the format of the XML file. This also gives me the flexibility to change my architecture at any time w/o affecting my affiliates.

I hope this example helps illustrate where XML can be useful as part of a PHP solution. Please feel free to post any further questions!

This discussion is closed to new replies.