I have and XML file which is constructed like so:
<Row>
<Cell><Data>Name</Data></Cell>
<Cell><Data>Surname</Data></Cell>
<Cell><Data>Email</Data></Cell>
</Row>
<Row>
<Cell><Data>Name</Data></Cell>
<Cell><Data>Surname</Data></Cell>
<Cell><Data>Email</Data></Cell>
</Row>
<Row>
<Cell><Data>Name</Data></Cell>
<Cell><Data>Surname</Data></Cell>
<Cell><Data>Email</Data></Cell>
</Row>
<Row>
<Cell><Data>Name</Data></Cell>
<Cell><Data>Surname</Data></Cell>
<Cell><Data>Email</Data></Cell>
</Row>
What I want to do is add them to a table using PHP so far I have written this code:
<?php
$dom = new DomDocument();
$dom -> load("file.xml");
$data = $dom->getElementsByTagName('Data');
echo( "<table><tr>");
foreach( $data as $node){ echo( "<td>". $node -> textContent . "<td>");}
echo( "</tr></table>");
?>
The problem is that its appending all the data to td tags which get really long and what I need it to do is add a tr tag after the 3 data tags that are read.
Its currently creating something like:
<table>
<tr>
<td>Name</td><td>Surname</td><td>Email</td>
<td>Name</td><td>Surname</td><td>Email</td>
<td>Name</td><td>Surname</td><td>Email</td>
<td>Name</td><td>Surname</td><td>Email</td>
</tr>
</table>
I need it to be
<table>
<tr><td>Name</td><td>Surname</td><td>Email</td></tr>
<tr><td>Name</td><td>Surname</td><td>Email</td></tr>
<tr><td>Name</td><td>Surname</td><td>Email</td></tr>
<tr><td>Name</td><td>Surname</td><td>Email</td></tr>
</table>
HELP! :-)