Tom:

Thanks for the help.  Using the array setup you described, I end up with the
value of each "record" node being appended to a single instance of the
parent node.  And that single instance of the parent node is the final one
that was parsed (the attributes verify this).  The example I used below is
outputting this:

<rootElement>
  <record id="2">Value 1Value 2</record>
</rootElement>

Any ideas?

--
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
"Tom Rogers" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> Wednesday, July 9, 2003, 10:38:22 AM, you wrote:
> MG> I'm having trouble creating objects with DOMXML.  As I loop through a
level
> MG> of nodes, I'm creating a new element based on the array's key name.
The XML
> MG> might look like this:
>
> MG> <rootElement>
> MG>   <record id="1">Value 1</record>
> MG>   <record id="2">Value 2</record>
> MG> </rootElement>
>
> MG> So I'd be doing this with DOMXML in a loop:
>
> $thisChild = $doc->>create_element($key);
> MG> $thisChild = $ancestor->append_child($thisChild);
>
> MG> Where $key is 'record' in this example, and $ancestor is
'rootElement',
> MG> which is carried along in the function.
>
> MG> The problem that when I reach the second element by the same name, and
in
> MG> the same node level, I'm overwriting the $thisChild object that I just
> MG> created.  How can I dynamically name these objects so that I can have
an
> MG> indeterminate number of elements by the same name, in the same level?
>
> What I have done is to keep an array of elements so it would work like
> this
>
> $elements = array();
>
> //loop
> if(!isset($elements[$key])){
>   $elements[$key] = $doc->create_element($key);
> }
> $thisChild = $ancestor->append_child($elements[$key]);
> //end loop
>
> -- 
> regards,
> Tom
>



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

Reply via email to