DOMDocument::createElementNS Crea un nuevo nodo elemento con el nombre de espacio asociado &reftitle.description; public DOMElementDOMDocument::createElementNS stringnamespaceURI stringqualifiedName stringvalue Esta función crea un nuevo nodo elemento con el nombre de espacio asociado. &dom.node.inserted; &reftitle.parameters; namespaceURI El URI del nombre de espacio. qualifiedName Elo nombre cualificado del elemento, como prefix:tagname. value El valor del elemento. De manera predeterminada se creará un elemento vacio. El valor también puede ser asignado más tarde con DOMElement::$nodeValue. &reftitle.returnvalues; El nuevo DOMElement o &false; si ha ocurrido un error. &reftitle.errors; DOM_INVALID_CHARACTER_ERR Lanzado si qualifiedName contiene un carácter inválido. DOM_NAMESPACE_ERR Lanzado si qualifiedName es un nombre cualificado mal formado. &reftitle.examples; Crear un nuevo elemento e insertarlo como raíz createElementNS('http://www.example.com/XFoo', 'xfoo:test', 'This is the root element!'); // Insertamos el nuevo elemento como raíz (hijo del documento) $dom->appendChild($element); echo $dom->saveXML(); ?> ]]> &example.outputs; This is the root element! ]]> Un ejemplo de prefijo de nombre de espacio formatOutput = true; $root = $doc->createElementNS('http://www.w3.org/2005/Atom', 'element'); $doc->appendChild($root); $root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:g', 'http://base.google.com/ns/1.0'); $item = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:item_type', 'house'); $root->appendChild($item); echo $doc->saveXML(), "\n"; echo $item->namespaceURI, "\n"; // Outputs: http://base.google.com/ns/1.0 echo $item->prefix, "\n"; // Outputs: g echo $item->localName, "\n"; // Outputs: item_type ?> ]]> &example.outputs; house http://base.google.com/ns/1.0 g item_type ]]> &reftitle.seealso; DOMNode::appendChild DOMDocument::createAttribute DOMDocument::createAttributeNS DOMDocument::createCDATASection DOMDocument::createComment DOMDocument::createDocumentFragment DOMDocument::createElement DOMDocument::createEntityReference DOMDocument::createProcessingInstruction DOMDocument::createTextNode