将XML节点复制到XML节点集合(PHP)

将XML节点复制到XML节点集合(PHP),php,xml,copy,Php,Xml,Copy,我有几个XML,其中包含来自一部电影的数据,我想用所有电影制作一个XML。。我怎么做 这是电影XML的一个示例: <movie> <popularity>0.018</popularity> <translated>true</translated> <adult>false</adult> <language>en</language> <original_name>Retu

我有几个XML,其中包含来自一部电影的数据,我想用所有电影制作一个XML。。我怎么做

这是电影XML的一个示例:

<movie>
<popularity>0.018</popularity>
<translated>true</translated>
<adult>false</adult>
<language>en</language>
<original_name>Return to Rajapur</original_name>
<name>Return to Rajapur</name>
<alternative_name>Retorno a Rajapur</alternative_name>
<type>movie</type>
<id>80261</id>
<imdb_id>tt0444415</imdb_id>
<url>http://www.themoviedb.org/movie/80261</url>
<overview>
A doomed love affair blooms against the beautiful and exotic backdrop of the deserts of India in this romantic drama. Samantha Hartley (Kelli Garner) is a woman in her early twenties who travels to Rajapur in India to visit a resort where her mother stayed years ago. While tracing the steps of her mother, Sara (Lynn Collins), Samantha learns the true story about her mother's stormy marriage to Jeremy (Justin Theroux), a charming but moody alcoholic. Only a few days after their wedding, Sara began to wonder if marrying Jeremy was a mistake, and while visiting India on their honeymoon, Sara met Jai Singh (Manoj Bajpai), a handsome and sensitive widower living in Rajapur. Jai Singh, who speaks fluent English, soon strikes up a friendship with Sara that quickly grows into a romance, but both are aware of the transgressive nature of their love, and their affair takes a tragic turn, leaving its scars on all parties involved.
</overview>
<votes>0</votes>
<rating>0.0</rating>
<tagline/>
<certification/>
<released>2006-11-01</released>
<runtime>97</runtime>
<budget/>
<revenue/>
<homepage/>
<trailer>http://www.youtube.com/watch?v=b2bc8dHUco4</trailer>
<categories></categories>
<keywords></keywords>
<studios></studios>
<languages_spoken>
<language_spoken code="en" name="English" native_name="English"/>
<language_spoken code="hi" name="Hindi" native_name=""/>
</languages_spoken>
<countries></countries>
<images>
<image type="poster" url="http://cf2.imgobject.com/t/p/w92/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="thumb" width="92" height="136" id="4ee0cac57b9aa14e0f00272e"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w154/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="w154" width="154" height="228" id="4ee0cac57b9aa14e0f00272e"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w185/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="cover" width="185" height="274" id="4ee0cac57b9aa14e0f00272e"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w342/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="w342" width="342" height="507" id="4ee0cac57b9aa14e0f00272e"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w500/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="mid" width="500" height="741" id="4ee0cac57b9aa14e0f00272e"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/original/tPuPbPCg0cAwWAAasVAyy4366BA.jpg" size="original" width="1120" height="1660" id="4ee0cac57b9aa14e0f00272e"/>
</images>
<cast>
<person name="Nanda Anand" character="" job="Director" id="589088" thumb="" department="Directing" url="http://www.themoviedb.org/person/589088" order="0" cast_id="1000"/>
<person name="Lynn Collins" character="" job="Actor" id="21044" thumb="http://cf2.imgobject.com/t/p/w185/berS11tKvXqTFThUWAYrH279cvn.jpg" department="Actors" url="http://www.themoviedb.org/person/21044" order="0" cast_id="1001"/>
<person name="Kelli Garner" character="" job="Actor" id="17442" thumb="http://cf2.imgobject.com/t/p/w185/tV4nlT3ApNd2iQMN2JGr6uCnoxX.jpg" department="Actors" url="http://www.themoviedb.org/person/17442" order="1" cast_id="1002"/>
<person name="Justin Theroux" character="" job="Actor" id="15009" thumb="http://cf2.imgobject.com/t/p/w185/hkJ8UaqMacoIiVkqu1AG69cIjMI.jpg" department="Actors" url="http://www.themoviedb.org/person/15009" order="2" cast_id="1003"/>
</cast>
<version>1</version>
<last_modified_at>2011-12-21 11:18:06 UTC</last_modified_at>
</movie>

0.018
真的
假的
EN
返回拉贾普
返回拉贾普
拉贾普猎犬
电影
80261
tt0444415
http://www.themoviedb.org/movie/80261
在这部浪漫的戏剧中,一段注定要失败的爱情在美丽而充满异国情调的印度沙漠背景下绽放。萨曼莎·哈特利(凯莉·加纳饰)是一位20出头的女性,她去印度拉贾普参观她母亲多年前住过的度假胜地。在追踪母亲莎拉(林恩·柯林斯饰)的脚步时,萨曼莎了解了她母亲与杰里米(贾斯汀·塞鲁克斯饰)风雨飘摇的婚姻的真实故事,杰里米是一个迷人但喜怒无常的酒鬼。就在他们结婚几天后,莎拉开始怀疑嫁给杰里米是否是一个错误。在蜜月期间,莎拉在印度遇到了贾伊·辛格(Manoj Bajpai),一位住在拉贾普的英俊而敏感的鳏夫。说一口流利英语的贾伊·辛格很快就与萨拉建立起了友谊,并很快发展成了一段爱情,但两人都意识到他们爱情的越轨性质,他们的婚外情发生了悲剧性的转变,给所有相关方留下了伤痕。
0
0
2006-11-01
97
http://www.youtube.com/watch?v=b2bc8dHUco4
1.
2011-12-21 11:18:06 UTC
我需要一个类似以下内容的XML:

<movies>
<movie>
</movie>
</movies>

我肯定有办法做到这一点,但我对PHP和XML还不熟悉,所以我需要帮助!
谢谢

这不是一个非常优雅的解决方案,但它可以工作:您可以读取每个文件并将其内容放在一个文件中:

<?php
$files = array("file1.xml","file2.xml","file3.xml");
$output = fopen("result.xml","w");
fwrite($output,"<movies>");
foreach ($files as $f)
{
    fwrite($output,file_get_contents($f));
}
fwrite($output,"</movies>");
?>

如果文件中没有xml prolog,这是一个非常好的解决方案