将多个xml文件合并到单个xml文件中

时间:2015-02-10 20:50:03

标签: xml macos

我需要将多个xml文件合并到一个xml文件中。我觉得这很容易,但我无法弄明白。是否有一个工具(osx)或我必须使用脚本?所有xml文件都是这样的。有没有办法将这些与php结合成一个文件?



<?xml version="1.0"?>
<trcitem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" availablefrom="2015-02-01T00:00:00" availableto="2015-02-08T00:00:00" trcid="2b7fde5b-56d7-4dc2-9b37-d8e5baa72ff3" createdby="info@1234.nl" creationdate="2015-02-01T13:23:57" lastupdated="2015-02-08T00:52:01" lastupdatedby="workflow@1234.nl" owner="VVV Altena Biesbosch Invoerders" wfstatus="approved" published="false" legalowner="info@1234.nl" lastimportedon="2015-02-01T13:23:58.023" deleted="false" offline="false" xmlns="http://www.vvvnederland.nl/XMLSchema/TrcXml/2.0">
  <calendar excludeholidays="false">
    <single date="07/02/2015">
      <when timestart="19:00:00" />
    </single>
  </calendar>
  <trcitemcategories>
    <types>
      <type catid="2.6.9">Gezelschap/orkest</type>
    </types>
    <soldout>false</soldout>
    <canceled>false</canceled>
  </trcitemcategories>
  <media>
    <file trcid="c4630ca2-ddef-41b7-a8f3-788cf59133d7" main="true">
      <filename>da599797-a9a1-4620-80c8-592657d4e97f.jpg</filename>
      <filetype>jpg</filetype>
      <hlink>http://media.ndtrc.nl/Images/20150201/da599797-a9a1-4620-80c8-592657d4e97f.jpg</hlink>
      <mediatype>photo</mediatype>
    </file>
  </media>
  <trcitemdetails>
    <trcitemdetail lang="de">
      <calendarsummary>Samstag 7 Februar 2015, 19:00 Uhr.</calendarsummary>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
    <trcitemdetail lang="en">
      <calendarsummary>Saturday 7 February 2015, 19:00 hour.</calendarsummary>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
    <trcitemdetail lang="fr">
      <calendarsummary>Samedi 7 Février 2015, 19:00 heure.</calendarsummary>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
    <trcitemdetail lang="nl">
      <calendarsummary>Zaterdag 7 februari 2015, 19:00 uur.</calendarsummary>
      <longdescription>&lt;p style="font-family: arial; font-size: 12px; line-height: 16px;"&gt;De Jeugdmuziekdag Altena wordt gehouden op 7 februari 2015 in &amp;rsquo;t Verlaat in Almkerk. Tijdens deze dag speel je samen met andere muzikanten in &amp;eacute;&amp;eacute;n groot orkest en wordt er gewerkt aan een concertprogramma onder leiding van professionele dirigenten. Het thema is &amp;ldquo;Movies Music&amp;rdquo;.&lt;br /&gt;
&lt;br /&gt;
Elkemuzikant tot 21 jaar uit het Land van Heusden en Altena die een muziekinstrument bespeelt dat voorkomt in een HaFaBra-orkest, is welkom. Je hoeft niet per se lid te zijn van een muziekvereniging.&lt;br /&gt;
&lt;br /&gt;
De opgaveatum sloot op 24-12-2014&lt;/p&gt;
&lt;p style="font-family: arial; font-size: 12px; line-height: 16px;"&gt;Het slotconcert begint om 19:00 uur en daarvoor is de entree gratis.&lt;/p&gt;</longdescription>
      <shortdescription>één groot orkest </shortdescription>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
    <trcitemdetail lang="it">
      <calendarsummary>Sabato 7 febbraio 2015, 19:00 Ora.</calendarsummary>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
    <trcitemdetail lang="es">
      <calendarsummary>Sábado 7 Febrero 2015, 19:00 Hora.</calendarsummary>
      <title>Jeugdmuziekdag Altena</title>
    </trcitemdetail>
  </trcitemdetails>
  <location>
    <address>
      <physical giscoordinateType="points">
        <city>ALMKERK</city>
        <country>NL</country>
        <housenr>1</housenr>
        <street>'t Verlaat </street>
        <zipcode>4286</zipcode>
        <giscoordinates>
          <giscoordinate>
            <xcoordinate>4,957688</xcoordinate>
            <ycoordinate>51,769918</ycoordinate>
          </giscoordinate>
        </giscoordinates>
        <xcoordinate>4,957688</xcoordinate>
        <ycoordinate>51,769918</ycoordinate>
      </physical>
    </address>
    <actor availablefrom="2015-02-01T13:23:57" createdby="info@vvv-altenabiesbosch.nl" creationdate="2015-02-01T13:23:57" trcid="13862988-5229-45a3-8500-214421ed1a02" lastupdated="2015-02-01T13:23:57" lastupdatedby="info@vvv-altenabiesbosch.nl" owner="Systeembeheerders">
      <actordetails>
        <actordetail lang="nl">
          <title>'t Verlaat</title>
        </actordetail>
      </actordetails>
      <contactinfo>
        <address>
          <physical>
            <city>ALMKERK</city>
            <country>NL</country>
            <housenr>1</housenr>
            <street>'t Verlaat </street>
            <zipcode>4286</zipcode>
            <giscoordinates>
              <giscoordinate>
                <xcoordinate>4,957688</xcoordinate>
                <ycoordinate>51,769918</ycoordinate>
                <label>'t Verlaat  1, 4286 ALMKERK, NL</label>
              </giscoordinate>
            </giscoordinates>
          </physical>
        </address>
      </contactinfo>
    </actor>
  </location>
  <userorganisation>VVV Altena Biesbosch</userorganisation>
</trcitem>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

假设您的每个XML文件格式正确,您可以通过打开新文件,添加XML声明(可选),创建新的根元素(必需)以及添加根来手动或以编程方式组合它们每个XML文件的元素到新的组合XML文件的根元素。

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <File1Root>...</File1Root>
  <File2Root>...</File2Root>
  <File3Root>...</File3Root>
</root>

注意:

  • 新的XML文件必须只有一个根元素,否则它不是很好。
  • 注意不要在。中包含多个XML声明 新的XML文件。
  • 您可能希望调整名称空间声明以确保新XML文件的一致性。