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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.