tags:

views:

62

answers:

2
ob_start();
echo '<'.'?xml version="1.0"?'.'>';
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;';
echo '<root>';
$hierarchy=$tree->getArray();
recursiveBuild($hierarchy[0]);
echo '</root>';
file_put_contents('file.xml', ob_get_contents());
ob_end_clean();

file_put_contents('file.xml', 'w+' ob_get_contents());

This is not working, its not updating the xml file automatically.

A: 

Have you checked the CHMOD?

whichdan
+2  A: 

The line

file_put_contents('file.xml', 'w+' ob_get_contents());

should generate a parse error, because of ob_get_contents following a string without any valid separator.

By the way, you don't have to specify 'w+' for file_put_contents (and even if you wanted, you can't), it's implicit. So you should replace the line with:

file_put_contents('file.xml', ob_get_contents());

You may have a look at the file_ put_contents documentation.

FWH