Change language

PHP DOMDocument createElementNS () function

Syntax:
DOMElement DOMDocument::createElementNS (string $namespaceURI, string  $qualifiedName, string $value)
Parameters:This function takes three parameters as above and described below:
  • $namespaceURI:This parameter contains the namespace URI.
  • $qualName:This parameter contains the full name of the element as a prefix: tagname.
  • $value:this parameter contains the value of the element. The default value of this parameter is empty or absent, which means that an empty element was created.
Return value:This function returns a new DOMElement on success or FALSE on failure .The following programs illustrate the DOMDocument::createElementNS() function in PHP:Program 1:  
// Create a new one DOMDocument $dom = new DOMDocument ( ’1.0’ , ’ utf-8’ );  
// Use the createElementNS() function to create a new one
// node element with associated namespace $element = $dom -> createElementNS ( https://www.engineerforengineer.org/php , ’php: function’ , ’Welcome to GeeksforGeeks’ );  
// Add a child element $dom -> appendChild ( $element );  
// Create an XML document and submit it echo $dom -> saveXML();  
?>
Exit:
  Welcome to GeeksforGeeks < / php: function >
Program 2:  
// Create a new DOMDocument $dom = new DOMDocument ( ’ 1.0’ , ’utf-8’ );  
// Use the createElementNS() function to create a new one
// node element with associated namespace $element1 = $dom -> createElementNS ( https://www.engineerforengineer.org/php , ’organization: GeeksforGeeks’ , ’A computer science portal’ ); $element2 = $dom -> createElementNS ( https://www.engineer.org/html , ’php: link’ , ’Welcome to GeeksforGeeks’ ); $element3 = $dom -> createElementNS ( https://www.engineerforengineer.org/algo , ’algo: link’ , ’Best coding platform’ );  
// Add a child element $dom -> appendChild ( $element1 ); $dom -> appendChild ( $element2 ); $dom -> appendChild ( $element3 );  
// Create an XML document and submit it echo $dom -> saveXML();  
?>
Exit:
 < organization: GeeksforGeeks xmlns: organization = "https://www.engineerforengineer.org/php" > A computer science portal < / organization: GeeksforGeeks >  Welcome to GeeksforGeeks < / php: link >  Best coding platform 
Link: https://www.php.net/ manual / en / domdocument.createelementns.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

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