How to use PHP DOM functions to create XML

Do you need to create XML using PHP? Then you can use the PHP DOM functions to create an XML file. If you have worked with PHP 4 earlier then there is a slight change in the syntax of PHP 5. It is easy to work with this syntax if you have already worked with the browser's DOM functions.


The new DomDocument() function is used to create a new DOM Document object. After creating the new document object, you can add elements to it using the document object's createElement() method.

Using this method you can create the different elements that are needed for the document. Suppose you want to add a text content to the particular node you can use the createTextNode() method to create the text node and then use appendChild() method to append that text node to any element of your choice.

Then append that element to the root node of the XML document using the same appendchild() method. Now you can save the XML to another file also or print it out in the browser.



SetApp - 100 Apps for everything you ever wanted to do on Mac

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.

_______________________________________








 

 

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!

Visit XML Training Material Guide Homepage

 

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.