JEdot JEdot - 1 year ago 76
PHP Question

How I can format this line into formatted code using regex

How I can convert this line :


into something formatted like :


using regex.

Also I dont understand why
(an instance of DOMDocument) return the result as one line only.

Answer Source

Actually using regex would be the longer option. Rather use

$doc->preserveWhiteSpace = false;
$doc->formatOutput = true;
$xml_string = $doc->saveXML();
echo $xml_string;

This should get you the formatted code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download