views:

332

answers:

1

I'm using PHP5 to create XML files. I have code like this:

$doc = new DOMDocument();
...
$xml_content = $doc->saveXML();

The problem is that created XML code starts with a root node like this one:

<?xml version="1.0"?>

But I want it to be like this:

<?xml version="1.0" standalone="yes" ?>

I guess I need to call some function on $doc, but I can't figure out which one?

+4  A: 

You want to set

$doc->xmlStandalone = true;

It's not a function of the class, it's a property so it's a little harder to find in the docs. You can read about it here.

Ciaran McNulty