remove xml version tag when a xml is created in php

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

    As SimpleXMLElement always uses "\n" to separate the XML-Declaration from the rest of the document, it can be split at that position and the remainder taken:

    explode("\n", $customXML->asXML(), 2)[1];
    

    Example:

    
    
    ');
    
    echo explode("\n", $customXML->asXML(), 2)[1];
    

    Output:

    
    
    
    

提交回复
热议问题