I’m using XMLWriter http://www.php.net/manual/en/book.xmlwriter.php to let my webclient create an XML File.
In the beginning there has to be an element with very many attributes, like this:
$xml->startElement('registry-request');
$xml->writeAttribute('att1', 'long text');
$xml->writeAttribute('att2', 'long text');
$xml->writeAttribute('att3', 'long text');
$xml->writeAttribute('att4', 'long text');
So that part in the XML file will look something like this:
<registry-request att1="long text" att2="long text" att3="long text" att4="long text">
Which with real input looks quite terrible.
I would much rather have it like this:
<registry-request att1="long text" att2="long text"
att3="long text" att4="long text">
I didn’t find a solution in the XMLWriter php.net documentation, anyone got an idea how to do this? Just adding typical linebreak commands like:
$xml->writeAttribute('att2', 'long text\n');
doesn’t help.
Thanks.
Actually the
$xml->setIndent(1);does exactly that. Surprisingly!