Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $padd = ' '; //4 spaces for identation
- $eol = "n"; //end of line
- $xml = '<?xml version="1.0"?>'.$eol;
- $xml .= '<products>'.$eol;
- foreach ($collection as $product) {
- $xml .= $padd.'<product>'.$eol;
- $xml .= str_repeat($padd, 2).'<name>'.$product->getName().'</name>'.$eol;
- $xml .= str_repeat($padd, 2).'<description><![CDATA['.$product->getName().']]></description>'.$eol;
- $xml .= str_repeat($padd, 2).'<price><![CDATA['.$product->getFinalPrice().']]></price>'.$eol;
- //add here all the attributes you need to export
- $xml .= $padd.'</product>'.$eol;
- }
- $xml .= '</products>'.$eol;
- //Do something with $xml - save it in a file or echo it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement