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>
0

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

caution: this does not create the expected output. mind the differences in the first namespace declaration: eval.in/204667

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.