11-30-2007, 03:20 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,239
Thanks: 3
|
Nice little article, I was going to write something similar but without using the DOM. One thing to point out, to save us tired fingers, is an easier/quicker method of attaching simple element structures (ie, a node with just some text) to the document.
sketchMedia's example (copied from above)
PHP Code:
foreach($row as $fieldname => $fieldvalue)
{
$child = $doc->createElement($fieldname);
$child = $car->appendChild($child);
//add data to the new element
$value = $doc->createTextNode($fieldvalue);
$value = $child->appendChild($value);
}
Salathe's example
Everything will work the same, honest.
It's just a personal preference but I like this approach better for simple elements.
PHP Code:
foreach($row as $fieldname => $fieldvalue)
{
$car->appendChild($doc->createElement($fieldname, $fieldvalue));
}
__________________
salathe@php.net
|
|
|
|