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");
Now to add the elements to the document object, you have to perform the following commands,
Now you are free to save that XML file or print it out on the screen.
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”Copyright - © 2004 - 2019 - All Rights Reserved.