Php Appendchild Example - Php

How to appendchild with PHP Dom?

Snippet Code

Rate this page :
  [ 0 votes]

Php appendchild which is used to add a node after the specified element of the node. Here, DOMNode->appendChild() is used to add a new child at the end of the children.

<?php $doc = new DOMDocument(); $doc->loadXML("<foobar><bar/><foo/></foobar>"); $bar = $doc->documentElement->firstChild; $foo = $doc->documentElement->lastChild; $foo->appendChild($bar); print $doc->saveXML(); ?>


Ask Questions

Ask Question