Change language

PHP DOMDocument createAttributeNS () function

Syntax:
DOMAttr DOMDocument::createAttributeNS (string $namespaceURI, string  $qualifiedName)
Parameters:This function takes two parameters as above and described below:
  • $namespaceURI: This parameter contains the namespace URI.
  • $qualNameThis parameter contains the tag name and attribute prefix. For example: prefix: tag.
Return value:This function returns a new DOMAttr object on success or FALSE on error.Below the program illustrates the DOMDocument::createAttributeNS() function in PHP:Program :  
// Save the XML document to the source $source = < < < XML " 1.0 " encoding = "UTF-8" ? & Gt; < root > < contact > < email > [email protected]< / email >
< mobile > + 91-987654321 < / mobile > < / contact > < / root >
XML;  
// Create a new document $domDocument = new DOMDocument ( ’1.0’ );  
// Load XML file $domDocument -> loadXML ( $source );  
// Use the createAttributeNS() function to create a new attribute
// node with associated namespace $attrNS = $domDocument -> createAttributeNS ( ’{namespace}’ , ’info: cont_info’ );  
// Create an XML document and display it echo $domDocument -> saveXML(). "" ;  
// Assign the value to createAttributeNS $attrNS -> value = https://www.engineerforengineer.org/about/contact-us/ ; $domDocument -> getElementsByTagName ( ’ contact’ ) -> item (0) -> appendChild ( $attrNS );  
// Create an XML document and display it print $domDocument -> saveXML(). "" ;  
?>
Exit:
 < root xmlns: info = "{namespace}" > < contact > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contact > < / root >  < root xmlns: info = "{namespace}" > < contact info: cont_info = "https://www.engineerforengineer.org/about/contact-us/"> < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contact > < / root >
Link: https://www.php.net/ manual / en / domdocument.createattributens.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