$doc = new DOMDocument(); $elem = $doc->createElementNS('http://www.w3.org/2000/svg', 'svg:path');
$doc = new DOMDocument('1.0', 'UTF-8'); $rootElem = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'html'); $headElem = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'head'); $titleElem = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'title', 'This is the title'); $bodyElem = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'body'); $paraElem = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'p', 'This is a paragraph'); $doc->appendChild($rootElem); $rootElem->appendChild($headElem); $headElem->appendChild($titleElem); $rootElem->appendChild($bodyElem); $bodyElem->appendChild($paraElem); echo $doc->saveXML();This code creates a new DOMDocument object, and uses the `createElementNS` method to create an XHTML document with a `title` element and a `paragraph` element, and prints the resulting XML document. The package/library used in this example is the core PHP library (as DOMDocument is built-in). In conclusion, the `createElementNS` method can be used to create new element nodes with specified namespace URIs and qualified names in PHP's core DOMDocument class.