Adding entities to the DOCTYPE using DomDocument

前端 未结 1 1067
灰色年华
灰色年华 2021-01-22 16:31

I\'m trying to create an XML document that looks something like this...




        
1条回答
  •  清歌不尽
    2021-01-22 17:08

    The DOM isn't an interface for building document type definitions, which is why you won't find methods for adding things like entity declarations to the internal subset. If you must inline it instead of using an external subset, you're going to have to provide it as a complete string and load it up accordingly.


    Example:

    $xml = <<<'XML'
    
        
        
        
        
        
        
        
        
        
    ]>
    
    XML;
    
    $dom = new DOMDocument();
    $dom->loadXML($xml);
    
    echo $dom->saveXML();
    

    Output:

    
    
    
    
    
    
    
    
    
    
    
    ]>
    
    

    0 讨论(0)
提交回复
热议问题