remove xml version tag when a xml is created in php

前端 未结 10 1895
星月不相逢
星月不相逢 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 10:56

    In theory you can provide the LIBXML_NOXMLDECL option to drop the XML declaration when saving a document, but this is only available in Libxml >= 2.6.21 (and buggy). An alternative would be to use

    $customXML = new SimpleXMLElement('');
    $dom = dom_import_simplexml($customXML);
    echo $dom->ownerDocument->saveXML($dom->ownerDocument->documentElement);
    

提交回复
热议问题