This section contains the detail about the loadXML() function in PHP.
PHP XML loadXML() Example:
If you want to load string data in the xml file then use loadXML() function. The loadXML() load xml from a string. This function return boolean (true for success or false for failure).
Example :
<?php $doc = new DOMDocument(); $doc->loadXML('<root><node>Rose India</node></root>'); $doc->save("test.xml"); echo $doc->saveXML(); ?>
After running this example the browser output is:
Rose India
and the generated test.xml file code is:
<?xml version="1.0"?> <root><node>Rose India</node></root>
[ 0 ] Comments