0

Thanks for your help, I need php script to generate the following XML

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <design xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://anydomain.com">
    <name>xxx</name>
  <description>yyy</description>
</design>
Kevin
  • 41,694
  • 12
  • 53
  • 70
Pundit
  • 229
  • 2
  • 7

1 Answers1

0

You could use SimpleXML to create such xml.

Rough example:

$xml = new SimpleXMLElement('<design />'); // set parent node
$xml->addAttribute('xmlns', 'http://anydomain.com'); // attributes
$xml->addAttribute('xlink:ns', '', 'http://www.w3.org/1999/xlink');

unset($xml->attributes('xlink', true)['ns']);
$xml->addChild('name', 'xxx'); // add those children
$xml->addChild('description', 'yyy');
echo $xml->asXML(); // output
Kevin
  • 41,694
  • 12
  • 53
  • 70
  • caution: this does not create the expected output. mind the differences in the first namespace declaration: https://eval.in/204667 – hakre Oct 11 '14 at 15:27