remove xml version tag when a xml is created in php

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

    A practical solution: you know that the first occurrence of ?> in the result string is going to be then end of the xml version substring. So:

    $customXML = new SimpleXMLElement('');
    $customXML = substr($customXML, strpos($customXML, '?'.'>') + 2);
    

    Note that ?> is split into two parts because otherwise some poor syntax highlighter may have problems parsing at this point.

提交回复
热议问题