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

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

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically