How to creating simple xml file using php.I’ll describes how to creating xml file by formatting tags using php.
createElement("Student"); // creatingopening root tag // Process closing root tag $xml->formatOutput = true; // formatting tags $xml->save("Students.xml"); // Save the file named "Student.xml" ?>tag $xml_name = $xml->createElement("Name"); // creating opening tag $xml_name->nodeValue = 'John doe'; // add value to the element $xml_student->appendChild($xml_name); // creating closing tag // Processtag $xml_country = $xml->createElement("Country"); // creating opening tag $xml_country->nodeValue = 'US'; // add value to the element $xml_student->appendChild($xml_country); // creating closing tag // Processtag $xml_email = $xml->createElement("Email"); // creating opening tag $xml_email->nodeValue = '[email protected]'; // add value to the element $xml_student->appendChild($xml_email); // creating closing tag $xml->appendChild($xml_student); // creating
That’s all.
Download PHP Creating XML file Example(2 KB)