Using domdocument, we can create xml document as we wish. Combined with the how-to-create-xml-in-php we will create xml directly in browser.
Here is the code to create xml from php :
Here is the code to create xml from php :
$domDocument = new DOMDocument('1.0', "UTF-8");
$domElement = $domDocument->createElement('field','some random data');
$domAttribute = $domDocument->createAttribute('name');
$domAttribute->value = 'attributevalue';
$domElement->appendChild($domAttribute);
$domDocument->appendChild($domElement);
header("Content-type: text/xml");
echo $domDocument->saveXML();
Here is the screenshot of the code above :

No comments:
Post a Comment