Formatting output to file with PHP DOMDocument

So I wrote this script that looks for certain nodes in an XML file, deletes it, and puts a new node in it's place... however, the new node is showing up like so:

<PrintQuestion id="17767" type="pickOne">

<Standards><Standard value="CA.MATH-6-6-20" state="CA" grade="3" subject="MATH"/></Standards><References>
        <PassageRef id="1892"/>
    </References>

I've attempted to use the $xml->formatOutput = true; but that has done nothing. I'm loading the dom object from an XML file and saving it back to the same file upon completion.

Answers


When you want to use

$xml->formatOutput = TRUE;

you also have to set

$xml->preserveWhiteSpace = FALSE; 

You wrote preserveWhitespace (mind the 2nd s). Properties are case-sensitive in PHP.

See difference on codepad


Need Your Help

how to run javascript in html loaded via ajax

php javascript html ajax xmlhttprequest

I have an index.php file that loads other php files via this javascript/ajax code:

Using Checkboxes in Dialog Sheet to Specify Sheets to Perform Actions

arrays excel vba dialog

I'm currently using the following code to reset an event/inventory/sales workbook. However, I was hoping to find a way to have the user select (via dialog sheet or userform with checkboxes) which ...