Skip to content

Instantly share code, notes, and snippets.

@supermethod
Created April 11, 2011 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supermethod/913396 to your computer and use it in GitHub Desktop.
Save supermethod/913396 to your computer and use it in GitHub Desktop.
Format SimpleXML xml output
$doc = new DOMDocument('1.0');
$doc->preserveWhiteSpace = false;
@$doc->loadXML( $xml->asXML() );
$doc->formatOutput = true;
//return as string
return $doc->saveXML();
//save as file
//return $doc->save('data.xml');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment