El Forum
03-23-2009, 04:37 PM
[eluser]Jérôme Jaglale[/eluser]
Download and documentation
New XML document
Add "book" element
Add "title" to "book"
Add "author" to "book"
Add "birthdate" attribute to "author"
Display XML document
Output
PHP 5 required. Based on DOMDocument.
Download and documentation
New XML document
Code:
$dom = xml_dom();
Add "book" element
Code:
$book = xml_add_child($dom, 'book');
Add "title" to "book"
Code:
xml_add_child($book, 'title', 'Hyperion');
Add "author" to "book"
Code:
$author = xml_add_child($book, 'author', 'Dan Simmons');
Add "birthdate" attribute to "author"
Code:
xml_add_attribute($author, 'birthdate', '1948-04-04');
Display XML document
Code:
xml_print($dom);
Output
Code:
<?xml version="1.0"?>
<book>
<title>Hyperion</title>
<author birthdate="1948-04-04">Dan Simmons</author>
</book>
PHP 5 required. Based on DOMDocument.