Dynamic XML with PHP

Friday Jan 19th 2007 by DatabaseJournal.com Staff
Share:

In this article I will show you how to generate dynamic XML documents with Object-Oriented PHP. We are going to create a method that dynamically creates XML output with only a record id and the table name to query from! Source code included!

[From PHPBuilder]

In this article I will show how to generate dynamic XML documents with Object-Oriented PHP. Before I get started, let's get right to the heart of this functionality. Although the code may look fancy, being packaged up inside objects and inheritance, the key elements of this functionality rest in the the mysql_list_fields() and mysql_num_fields() functions.

What they do is get a field list array and a column count for a given table in a database. The way that we'll be able to have a generic XML output method in our class is by taking advantage of these features. So, in simplicity, instead of outputting our XML by handcoded column names, we are going to create a method that dynamically creates XML output with only a record id and the table name to query from. The implementation, however, is a bit more complex.

The article continues at http://www.phpbuilder.com/columns/ben_robinson200701017.php3

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved