Posted by jonKushner@gmail.com on 01/12/08 00:50
On Jan 11, 12:34 pm, yawnmoth <terra1...@yahoo.com> wrote:
> <?php
> $xml = new DOMDocument();
> $xml->loadXML('
> <a>
> <b>test</b>
> </a>
> ');
>
> $temp = $xml->createElement('b');
> $temp->appendChild($xml->createTextNode('test'));
> $xml->firstChild->appendChild($temp);
>
> echo '<pre>';
> echo htmlspecialchars($xml->saveXML());
> echo '</pre>';
>
> ?>
>
> I'd like for this to be able to return this:
>
> <a>
> <b>test</b>
> <b>test</b>
> </a>
>
> Instead, it produces this:
>
> <a>
> <b>test</b>
> <b>test</b></a>
>
> ie. the indentation convention that I'm using isn't being used by
> saveXML(). Setting $xml->preserveWhiteSpace and $xml->formatOutput to
> true doesn't seem to help.
>
> Any ideas as to what - if anything - I can do?
I don't think this is going to help your cause, but maybe it is
because you are not including \n. To me, this looks just fine though :)
[Back to original message]
|