Introduction on using PHP to create XML documents

You can create XML documents using the PHP DOM. If you have worked earlier in any script or language using DOM then you can very well work with the PHP DOM too. As with other language you have to first create a new document object.

_______________________________________________


_______________________________________________

The DOM has lot of function like createElement, createTextNode etc which can be used to create an element and to create a text node for an element. Then you can use add the textnode to an element and that element to another element and so on using the appendChild function.

Suppose you have create a new document object using the following command,

$domobj = new DomDocument();

Then you can create an element using command like,

$book = $domobj->createElement("book");
$author = $domobj->createElement("author");
$authtext = $domobj->createTextNode("Jeffrey Archer");

Now to add the elements to the document object, you have to perform the following commands,

$author->appendChild($authtext);
$book->appendChild($author);
$domobj->documentElement->appendChild($book);

Now you are free to save that XML file or print it out on the screen.

New Subscription-free Audio Books for iPods Launched by BooksOnBoard (PR Newswire via Yahoo! Finance)
Downloading audio books by John Grisham, James Patterson and others to audio devices - like iPods - just became a little easier and cheaper.

Linked by Thom Holwerda on Wed 13th Jul 2005 17:02 UTC (New Mobile Computing)
This tutorial is part I of a three-part series ( part II | part III ) that takes you from the most basic PHP script to working with databases and streaming from the file system by documenting the building of a document workflow system.

INTERFAX - Hungary Business news report of 04.07.2008 (Girodivite)
Updated news from Hungary Saturday 5 July 2008, by Emanuele G. - 0 letture Girodivite - Segnali dalle città invisibili è on-line dal 1994. Quotidiano telematico e cartaceo, registrazione presso il tribunale di Catania n.13/2004 del 14/05/2004. Redazione: via Antonino di Sangiuliano 147 - 95131 Catania.


FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________

Recommended XML Books

cover
cover
cover
cover
cover
cover



 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!


New XML Books Titles - Best Seller's @ Amazon.com

Visit XML Training Material Guide Homepage

Technology helps engage students - how do classroom instruction and social dynamics change when the classroom is completely dependant on modern technology?

Dallas Web Design- local Dallas web design firm offers site design and backend system development