php SimpleXml 如何正确设置编码和 xmins?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5992268/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SimpleXml how to correctly set encoding and xmins?
提问by Cups
Any ideas on how I can get PHPs SimplXMLElement to kick off with the following?
关于如何让 PHP SimplXMLElement 从以下开始的任何想法?
<?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?
还是我使用 simplexml_load_string() 来设置它?
Context: I am extending simpleXmlElement to create some kml files.
上下文:我正在扩展 simpleXmlElement 以创建一些 kml 文件。
EDIT
编辑
Actually, setting the kml xmlns was laughably easy to do:
实际上,设置 kml xmlns 很容易做到:
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.
只是如何设置令我烦恼的 encoding="UTF-8" ,似乎没有那个 kml 是可以接受的,但我仍然想了解如果 pos.
回答by OZ_
new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>'
.'<kml xmlns="http://earth.google.com/kml/2.2">'
.'<Document></Document></kml>');