SimpleXml如何正确设置编码和xmins? [英] SimpleXml how to correctly set encoding and xmins?

查看:133
本文介绍了SimpleXml如何正确设置编码和xmins?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何关于如何让PHP SimplXMLElement以以下方式启动的想法?

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">

主根将是:

<Document></Document>

还是使用simplexml_load_string()来设置?

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

上下文:我正在扩展simpleXmlElement以创建一些kml文件。

Context: I am extending simpleXmlElement to create some kml files.

编辑

实际上,设置kml xmlns是很容易做到的:

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

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

只是如何设置编码=UTF-8这是困扰我,似乎kml是可以接受的没有这个,但是我仍然想了解如果pos。

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>');

这篇关于SimpleXml如何正确设置编码和xmins?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆