非常简单,我有一个数组,其中有许多具有相同结构的节点作为简单XML对象(从不同的XML文档中提取)。将它们添加到单个XML文档中以便输出组合XML的最简单方法是什么?我已经找过了,但我找不到一个好的解决办法。
编辑:数组看起来像这样,我如何在一个单一的XML对象组合这些对象?
Array (
[0] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[no] => 23432423
[type] => Array
)
[id] => 40043030
[title] => Cars
[cinemadate] => 2011-07-06
[changedate] => 2011-07-27T10:19:00
[year] => 2011
[length] => 112
[genres] => SimpleXMLElement Object
(
[genre] => animatie
)
[1] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[no] => 48050593
[type] => Array
)
[id] => 1231676
[title] => Arrietty
[cinemadate] => 2011-07-06
[changedate] => 2011-06-21T10:39:00
[genres] => SimpleXMLElement Object
(
[genre] => animatie
)
遍历数组并将数据添加到现有的simplexml对象中。您没有在您的问题中提供太多的信息,数组数据看起来像什么,也没有提供一个示例simplexml对象/xml块,所以没有更多的具体说。