Jump to content

php to xml help


ballhogjoni

Recommended Posts

Can anyone tell what is invalid about this php to xml code?

<?php
$doc = new_xmldoc('1.0');
$root = $doc->add_root('checkout-shopping-cart');
$shopping_cart = $root->new_child('shopping-cart','');
$items = $shopping_cart->new_child('items','');
$item = $items->new_child('item','');
$item->new_child('item-name','$5 off all Valentines Day Orders');
$item->new_child('item-description','Save $5 today only!');
$item->new_child('unit-price currency="USD"','-5.00');
$item->new_child('quantity','1');
$item = $items->new_child('item','');

$fp = @fopen('members.xml','w+');
if(!$fp) {
    die('Error cannot create XML file');
}
fwrite($fp,$doc->dumpmem());
fclose($fp);

?>

Link to comment
https://forums.phpfreaks.com/topic/58994-php-to-xml-help/
Share on other sites

O i figured our what the error is, how do you fix it? This is the xml file but the xml reader in the browser cannot publish it to the web page because of the closing tag on this line. The code in my last post closes the tag automatically with the same as the opening tag.

 

<unit-price currency="USD">-5.00</unit-price currency="USD">

Link to comment
https://forums.phpfreaks.com/topic/58994-php-to-xml-help/#findComment-292770
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.