Change language

PHP DOMDocument saveHTML () function

Syntax:
string DOMDocument::saveHTML (DOMNode $node = NULL)
Parameters:This function takes one parameter, $node,which is optional and is used to display a subset of the document.Return value: this function returns an HTML document on success or FALSE on error.The following program illustrates the DOMDocument::saveHTML() function in PHP:Program:  
// Create a new DOMDocument $domDocument = new DOMDocument ( ’1.0’ );  
// Create root element $root = $domDocument -> createElement ( ’html’ );  
// Add an element to the document as the root element $root = $domDocument -> appendChild ( $root );  
// Create the head element $head = $domDocument -> createElement ( ’head’ );  
// Add an element to the document
// as a child $head = $root -> appendChild ( $head );  
// Create header element $title = $domDocument -> createElement ( ’title’ );  
// Add an element to the document
// as a child $title = $head -> appendChild ( $title );  
// Create text node $text = $domDocument -> createTextNode ( ’DOMDocument::saveHTML() function’ );  
// Add a text node to the title element $text = $title -> appendChild ( $text );  
// Create body element $body = $domDocument -> createElement ( ’body’ );  
// Add an element to the document
// as a child $body = $root -> appendChild ( $body );  
// Create header element $h1 = $domDocument -> createElement ( ’h1’ );  
// Add an element to the document $h1 = $body -> appendChild ( $h1 );  
// Create text node $text = $domDocument -> createTextNode ( ’GeeksforGeeks’ );  
// Add a text node to the header element $text = $h1 -> appendChild ( $text );  
// Create header element $h2 = $domDocument -> createElement ( ’h2’ );  
// Add an element to the document $h2 = $body -> appendChild ( $h2 );  
// Create text node $text = $domDocument -> createTextNode ( ’DOMDocument::saveHTML() function’ );  
// Add a text node to the header element $text = $h2 -> appendChild ( $text );  
// Use saveHTML() function to create
// HTML document echo $domDocument -> saveHTML();  
?>
Output:
  < title > DOMDocument::saveHTML() function < / title > < / head >  

GeeksforGeeks < / h1 > 

DOMDocument::saveHTML() function

  < / html >
Link: https://www .php.net / manual / en / domdocument.savehtml.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method