Object assignment
| From: | Matt Grimm | Date: | Wed, 09 Jul 2003 00:38:22 +0000 |
| Subject: | Object assignment | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-154457@lists.php.net to get a copy of this message | ||
I'm having trouble creating objects with DOMXML. As I loop through a level
of nodes, I'm creating a new element based on the array's key name. The XML
might look like this:
<rootElement>
<record id="1">Value 1</record>
<record id="2">Value 2</record>
</rootElement>
So I'd be doing this with DOMXML in a loop:
$thisChild = $doc->create_element($key);
$thisChild = $ancestor->append_child($thisChild);
Where $key is 'record' in this example, and $ancestor is 'rootElement',
which is carried along in the function.
The problem that when I reach the second element by the same name, and in
the same node level, I'm overwriting the $thisChild object that I just
created. How can I dynamically name these objects so that I can have an
indeterminate number of elements by the same name, in the same level?
Source:
http://www.healthtvchannel.org/test/php2xml.phps
Thanks,
--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: mgrimm@healthtvchannel.org
Web: www.healthtvchannel.org