pretty xml

This commit is contained in:
Sergio Álvarez 2022-09-20 13:21:29 +02:00
parent 50c7faa7cd
commit cdd65d4c7f
1 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,7 @@ $buttons = [
'hash' => 'Hash', 'hash' => 'Hash',
'hex' => 'Hex', 'hex' => 'Hex',
'prettyjson' => 'Pretty JSON', 'prettyjson' => 'Pretty JSON',
'prettyxml' => 'Pretty XML',
'serializedtojson' => 'PHP Serialized to JSON', 'serializedtojson' => 'PHP Serialized to JSON',
]; ];
@ -109,6 +110,15 @@ if ($action == 'reset') {
} }
$help = 'https://www.php.net/json'; $help = 'https://www.php.net/json';
} elseif ($action == 'prettyxml') {
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
@$dom->loadXML($str);
$result = @$dom->saveXML();
$help = 'https://www.php.net/DOMDocument';
} elseif ($action == 'serializedtojson') { } elseif ($action == 'serializedtojson') {
$stdClass = preg_replace('~O:[0-9]+:"[^"]+"~', 'O:8:"stdClass"', $str); $stdClass = preg_replace('~O:[0-9]+:"[^"]+"~', 'O:8:"stdClass"', $str);
$unserialized = @unserialize($stdClass); $unserialized = @unserialize($stdClass);