remove xml version tag when a xml is created in php

前端 未结 10 1883
星月不相逢
星月不相逢 2020-11-28 10:28

I\'m creating a xml using this

$customXML = new SimpleXMLElement(\'\');

after adding some attributes onto this, when

10条回答
  •  忘掉有多难
    2020-11-28 11:18

    There's another way without the replacing xml header. I prefer this:

    $xml = new xmlWriter();
    $xml->openMemory();
    $xml->startElement('abc');
    $xml->writeAttribute('id', 332);
    $xml->startElement('params');
    $xml->startElement('param');
    $xml->writeAttribute('name', 'aa');
    $xml->text('33');
    $xml->endElement();
    $xml->endElement();
    echo $xml->outputMemory(true);
    

    Gives output:

    33
    

提交回复
热议问题