PHP | DOMDocument normalizeDocument() Function Last Updated : 30 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The DOMDocument::normalizeDocument() function is an inbuilt function in PHP which is used to normalize the document. This function is used to convert the document into the normal form if you saved and then loaded the document. Syntax: void DOMDocument::normalizeDocument( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the DOMDocument::normalizeDocument() function in PHP: Program 1: php <?php // Create a new document $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Create an element $domElement = $domDocument->createElement('organization', 'GeeksforGeeks'); // Append element to the document $domDocument->appendChild($domElement); // Use normalizeDocument() function // to normalize the document $domDocument->normalizeDocument(); // Create the XML file and display it echo $domDocument->saveXML(); ?> Output: <?xml version="1.0" encoding="iso-8859-1"?> <organization>GeeksforGeeks</organization> Program 2: php <?php // Create a new document $domDocument = new DOMDocument('1.0', 'iso-8859-1'); // Create an element $domElement1 = $domDocument->createElement('organization'); $domElement2 = $domDocument->createElement('name', 'GeeksforGeeks'); $domElement3 = $domDocument->createElement('address', 'Noida'); $domElement4 = $domDocument->createElement('email', '[email protected]'); // Append element to the document $domDocument->appendChild($domElement1); $domElement1->appendChild($domElement2); $domElement1->appendChild($domElement3); $domElement1->appendChild($domElement4); // Use normalizeDocument() function // to normalize the document $domDocument->normalizeDocument(); // Create the XML file and display it echo $domDocument->saveXML(); ?> Output: <?xml version="1.0" encoding="iso-8859-1"?> <organization> <name>GeeksforGeeks</name> <address>Noida</address> <email>[email protected]</email> </organization> Reference: https://www.php.net/manual/en/domdocument.normalizedocument.php Comment More infoAdvertise with us Next Article PHP | DOMDocument normalizeDocument() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP | DOMDocument load() Function The DOMDocument::load() function is an inbuilt function in PHP which is used to load an XML document from a file. Syntax: mixed DOMDocument::load( string $filename, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $filename: This parameter h 1 min read PHP | DOMNode normalize() Function The DOMNode::normalize() function is an inbuilt function in PHP which is used to remove empty text nodes and merge adjacent text nodes in this node and all its children. Syntax: void DOMNode::normalize( void ) Parameters: This function doesnât accept any parameters. Return Value: This function does 2 min read PHP | DOMDocument loadXML() Function The DOMDocument::loadXML() function is an inbuilt function in PHP which is used to load the XML file from a string. Syntax: mixed DOMDocument::loadXML( string $source, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $source: This parameter 2 min read PHP | DOMDocument loadHTML() Function The DOMDocument::loadHTML() function is an inbuilt function in PHP which is used to load HTML file from a string. Syntax: bool DOMDocument::loadHTML( string $source, int $options = 0 ) Parameters: This function accepts two parameters as mentioned above and described below: $source: This parameter ho 2 min read PHP | DOMDocument getElementById() Function The DOMDocument::getElementById() function is an inbuilt function in PHP which is used to search for an element with a certain id. Syntax: DOMElement DOMDocument::getElementById( string $elementId ) Parameters:This function accepts a single parameter $elementId which holds the id to search for. Retu 2 min read Like