3

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.

1

1 Answer 1

11

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

Sign up to request clarification or add additional context in comments.

1 Comment

WOW... I can't believe I didn't notice that. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.