XML tags closing before value being inserted
<p>The following code:</p>

<pre><code>// Read Attendees Data (For Organisation)
$attendServ = new AttendeeService();
$attendData = $attendServ-&gt;getAllActiveAttendeeByOrg($organisation_id);

$attendee = new DOMDocument('1.0');
$attendee-&gt;formatOutput = true;

$root = $attendee-&gt;createElement('attendee');
$root = $attendee-&gt;appendChild($root);

for ($i=0;$i&lt;count($attendData);$i++) {

    $row = $attendee-&gt;createElement('row');
    $row = $root-&gt;appendChild($row);

    foreach ($attendData[$i] as $tag=&gt;$value)
    {
        $nodename = $attendee-&gt;createElement($tag);
        $nodename = $row-&gt;appendChild($nodename);

        $nodevalue = $attendee-&gt;createTextNode($value);
        $nodevalue = $row-&gt;appendChild($nodevalue);
    }
}

// Test Organisation Output
header ("Content-Type:text/xml");
echo $attendee-&gt;saveXML();
</code></pre>

<p>Produces:</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;attendee&gt;
  &lt;row&gt;
    &lt;attendee_id/&gt;1
    &lt;attendee_name/&gt;A
    &lt;attendee_initials/&gt;A.1.
  &lt;/row&gt;
&lt;/attendee&gt;
</code></pre>

<p>Instead of:</p>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;attendee&gt;
  &lt;row&gt;
    &lt;attendee_id&gt;1&lt;/attendee_id&gt;
    &lt;attendee_name&gt;A&lt;/attendee_name&gt;
    &lt;attendee_initials&gt;A.1.&lt;/attendee_initials&gt;
  &lt;/row&gt;
&lt;/attendee&gt;
</code></pre>

<p>Any clue where I am going wrong?</p>
