开发者

SimpleXml how to correctly set encoding and xmins?

开发者 https://www.devze.com 2023-03-06 04:27 出处:网络
Any ideas on how I can get PHPs SimplXMLElement to kick off with the following? <?xml version=\"1.0\" encoding=\"UTF-8\"?>

Any ideas on how I can get PHPs SimplXMLElement to kick off with the following?

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">

The main root will then be:

<Document></Document>

Or do I use simplexml_load_string() to set it up?

Context: I am extending simpleXmlElement to create some kml 开发者_StackOverflow中文版files.

EDIT

Actually, setting the kml xmlns was laughably easy to do:

new simpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.2">
<Document></Document></kml>');

Just how to set encoding="UTF-8" that is bothering me, seemingly the kml is acceptable without that, but I'd still like to understand how to do it if pos.


new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
                          .'<kml xmlns="http://earth.google.com/kml/2.2">'
                          .'<Document></Document></kml>');
0

精彩评论

暂无评论...
验证码 换一张
取 消