I'm afraid I can't find an answer to this. I'm just trying this simple PHP DOM/XML example to understand how it should work since I'm new to this.
My error is:
Warning: domnode::append_child() expects parameter 1 to be object, null given in line 6
which is this line:
Here is the full code:
My error is:
Warning: domnode::append_child() expects parameter 1 to be object, null given in line 6
which is this line:
Code:
$xmlDocument->append_child($documentElement);
Here is the full code:
Code:
<?php
ini_set('display_errors', 1);
$xmlDocument = domxml_new_doc('1.0');
$documentElement = $xmlDocument->create_element('forest');
$xmlDocument->append_child($documentElement);
$tree = $xmlDocument->create_element('tree');
$name = $xmlDocument->create_element('name');
$name->append_child($xmlDocument->create_text_node('Oak'));
$tree->append_child($name);
$documentElement->append_child($tree);
$xmlDocument->dump_file('test2005.xml', FALSE, TRUE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test 2</title>
</head>
<body>
<p>
<a href="test2005.xml">test XML file</a>
</p>
</body>
</html>