I believe you'll need to change this line:
$newTile = $dom->createElement('div');
to:
$newTile = $root->createElement('div');
Eric
On Fri, Feb 29, 2008 at 1:37 PM, Nathan Lane <[EMAIL PROTECTED]> wrote:
> Inline in my web page I have the following:
>
> $map_container_width = 50;
> $map_container_height = 50;
> $dom = new DOMDocument('1.0', 'utf-8');
>
> $root = $dom->createElement('div');
> $root->setAttribute('id', 'mapContainer');
> $root->setAttribute('class', 'mapContainer');
>
> $dom->appendChild($root);
>
> for($i = 0; $i < $map_container_width; $i += 1) {
> for($j=0; $j < $map_container_height; $j += 1) {
> $tileId = 'tile-' . $i . ',' . $j;
> $newTile = $dom->createElement('div');
> $newTile->setAttribute('id', $tileId);
> //echo 'hello ' . $tileId;
> $newTile->setAttribute('class', 'laidTile');
>
> $root->appendChild($newTile);
> }
> }
>
> echo $dom->saveXML();
>
> So my problem is that instead of appending each of the new elements after
> each other, this is nesting the new elements inside of each other - anybody
> know why? I can't figure it out.
>
> Please help,
>
> --
> Nathan Lane
> Home, http://nathandelane.awardspace.com
>
> _______________________________________________
>
> UPHPU mailing list
> [email protected]
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
>
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net