Indentation
Closed this issue · 0 comments
quimm2003 commented
Hi there,
Just to inform.
I'm working in a project where all xml nodes must be indented to be accepted by a remote server. So I've tweaked the XMLSecurityDsig constructor like this:
public function __construct($prefix='ds', $formatOutput=FALSE)
{
$template = self::BASE_TEMPLATE;
if (! empty($prefix)) {
$this->prefix = $prefix.':';
$search = array("<S", "</S", "xmlns=");
$replace = array("<$prefix:S", "</$prefix:S", "xmlns:$prefix=");
$template = str_replace($search, $replace, $template);
}
$sigdoc = new DOMDocument();
if ($formatOutput === TRUE) {
$sigdoc->preserveWhiteSpace = FALSE;
$sigdoc->formatOutput = TRUE;
}
$sigdoc->loadXML($template);
$this->sigNode = $sigdoc->documentElement;
}
And get the final xml properly indented.
Thank you all.