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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.