Since I can't see the source for append_child(), I'll assume you're using
the $key as the index??

If so, try changing it to just a numeric index, ie, 0, 1, 2, etc.

HTH
Martin

-----Original Message-----
From: Matt Grimm [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 9 July 2003 10:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Object assignment


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: [EMAIL PROTECTED]
Web: www.healthtvchannel.org



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__________ Information from NOD32 1.452 (20030703) __________

This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to