简单的xml添加命名空间的子级 [英] simple xml add namespaced child
本文介绍了简单的xml添加命名空间的子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用SimpleXML为Google产品创建RSS提要,但我想创建一个有名称空间的子级,但是例如当我这样做时
I'm using SimpleXML to create an RSS feed for Google Products and I want to create a namespaced child but when I do for example
$item->addChild('g:id', 'myid');
它添加了
<id>myid</id>
代替
<g:id></g:id>
除了我在顶部添加的内容
Besides I have added at the top
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
如何添加命名空间的子代?
How can I add namespaced children?
推荐答案
名称空间是addChild()
$item->addChild('id', 'myid', 'http://base.google.com/ns/1.0');
请参阅文档以获取更多信息.
这篇关于简单的xml添加命名空间的子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文