I’m trying to combine two or more xml files for better use. Let’s say I have two XML files and I want to combine their content before extract their data into a table.
<table id="rounded-corner">
<tr>
<th>Title</th>
<th>Download Link</th>
<th>Language</th>
</tr>
<?php
$xml_request_url = 'file.xml';
$xml = new SimpleXMLElement($xml_request_url, null, true);
foreach ( $xml->results->content as $item )
{
echo "
<tr><td>" . $item->movie . "</td><td><a href=" . $item->download . ">Download Link</a> </td><td>" . $item->language . "</td></tr>
";
}
?> </table>
Can you give me an example of how to do it? I don’t want to make tables for each XML file I have.
<find>
<base>
http://www.example.com
</base>
<results items="2" itemsfound="2">
<song>
<downloadlink>
http://example.com/dldlink.php?lk=43543
</downloadlink>
<format>
mp3
</format>
</song>
<song>
<downloadlink>
http://example.com/dldlink.php?lk=87798
</downloadlink>
<format>
mp4
</format>
</song>
</results>
</find>
Your question actually is not asking about how to join two XML files, but more precisely how to create one iterator out of the two. That’s possible by using the
AppendIterator: