Pretty print (format) XML with PHP DOM


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $doc = new DOMDocument();
  4. $doc->preserveWhiteSpace = false;
  5. $doc->formatOutput = true;
  6. $doc->load('my.xml');
  7.  
  8. print $doc->saveXML();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.