$dom = new DOMDocument("1.0");
$root = $dom->createElement("thumbnails");
$dom->appendChild($root);
$dom->formatOutput=true;
$item = $dom->createElement("thumbnail");
$root->appendChild($item);
$text = $dom->createTextNode("pepperoni");
$item->appendChild($text);
$price = $dom->createAttribute("price");
$item->appendChild($price);
$priceValue = $dom->createTextNode("4");
$price->appendChild($priceValue);
$cdata = $dom->createCDATASection("\nCustomer requests that pizza be sliced into 16 square pieces\n");
$root->appendChild($cdata);
$dom->save("order.xml");
$order = $dom->save("order.xml");
the output would be like this
<?xml version="1.0"?> <thumbnails><thumbnail price="4">pepperoni</thumbnail><![CDATA[ Customer requests that pizza be sliced into 16 square pieces ]]></thumbnails>
Now what i want is to have a loop of that one. Display not just one but multiple ones. And i want to have the arrangement like this.
<?xml version="1.0" encoding="utf-8"?> <thumbnails> <thumbnail id="0" thumbs_url="thumb/test.jpg" image_url="test.jpg" title="Test" link="http://www.google.com"> <![CDATA[Test ]]> </thumbnail> </thumbnails>
Any suggestions on how to do it?


Sign In
Create Account


Back to top









