I am using the addChild() method with simpleXml, but for some reason I cant seem to close off my <item> node properly, either that or <item> node was not opened properly
Here is my array print out
SimpleXMLElement Object ( [item] => Array ( [0] => SimpleXMLElement Object ( [contract] => 1234 [price] => 4.99 [name] => Image converter ) [1] => SimpleXMLElement Object ( [contract] => 5678 [price] => 9.99 [name] => Silver membership ) ) )
I am trying addChild() in this manner
PHP Code:
$xmlString = $_SESSION['cart'].'</cart>';
$cart = new SimpleXMLElement($xmlString);
$items = $cart->addChild('item');
$items->addChild('contract', '1234');
$items->addChild('price', '14.99');
$items->addChild('name', 'Video Converter');
It pulls in the xml file from a session attatchs the closing </cart> node then makes it an object.
further more when I try to echo to the page with a foreach loop, it produces no content, plus the foreach loop is iterating 3 times when there is only 2 items to iterate through
Any thoughts?