Change language

PHP DOMDocument importNode () function

Syntax:
DOMNode DOMDocument::importNode (DOMNode $importedNode, bool  $deep = FALSE)
Parameters:This function takes two parameters as above and described below:
  • $importNode :this parameter contains the node to be imported.
  • $deep:this parameter contains a boolean value. If set to TRUE, it will recursively import the subtree in the imported node.
Return Value:This function returns the copied node on success or FALSE if it is not possible copy.The following program illustrates the DOMDocument::importNode() function in PHP:Program :  
// Create a new one document $dom = new DOMDocument;  
// Load XML document $dom -> loadXML ("< root > < contact > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contact > < / root > ");  
// Use the getElementsByTagName() function to search
// all elements with the given local tag name $node = $dom -> getElementsByTagName ( " contact " ) -> item (0);  
// Create a new document $dom1 = new DOMDocument; $dom1 -> formatOutput = true;  
// Load XML document $dom1 -> loadXML ("< root > < contactinfo > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contactinfo > < / root > "); echo " Document before copying the nodes " ;  
// Save the file as XML and display it echo $dom1 -> saveXML();  
// Use the importNode() function to import the node $node = $dom1 -> importNode ( $node , true);  
// Add a child element to the document $dom1 -> documentElement-> appendChild ( $node ); echo " Document after copying the nodes " ;  
// Save the XML document and display it echo $dom1 -> saveXML();  
?>
Exit:
Document before copying the nodes  < root > < contactinfo > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contactinfo > < / root > Document after copying the nodes  < contactinfo > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contactinfo > < contact > < email > [email protected]< / email > < mobile > + 91-987654321 < / mobile > < / contact > < / root >
Link: https://www.php.net/ manual / en / domdocument.importnode.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