tags:

views:

41

answers:

1

Hi ,

I need to add in a $person into the area were you add a value into addChild ,So it add's the value fo $person it into my xml file

$person->addChild('first_name', $person);

I know this is wrong but could some one explain why ?

Thanks

A: 

Second argument of SimpleXMLElement::addChild is only used for string values, like:

<first_name>Oliver</first_name>

If you have subelements in the element, you have to create them without specifying a string value (a subelement created will be returned by addChild), and then populate with attributes, values, and sub-elements of their own.

Ivan Krechetov