in Deutsh
in French
in Polish

You Are At Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

DOMDocument->createElement()

(no version information, might be only in CVS)

DOMDocument->createElement() -- Create new element node

Description

class DOMDocument {

DOMElement createElement ( string name [, string value] )

}

This function creates a new instance of class DOMElement. This node will not show up in the document unless it is inserted with e.g. DOMNode->appendChild().

Parameters

name

The tag name of the element.

value

The value of the element. By default, an empty element will be created. You can also set the value later with DOMElement->nodeValue.

Return Values

Returns a new instance of class DOMElement or FALSE if an error occured.

Errors/Exceptions

DOM_INVALID_CHARACTER_ERR

Raised if name contains an invalid character.

Examples

Example 1. Creating a new element and inserting it as root

<?php

$dom
= new DOMDocument('1.0', 'iso-8859-1');

$element = $dom->createElement('test', 'This is the root element!');

// We insert the new element as root (child of the document)
$dom->appendChild($element);

echo
$dom->saveXML();
?>

The above example will output:

<?xml version="1.0" encoding="iso-8859-1"?>
<test>This is the root element!</test>

See Also

DOMNode->appendChild()
DOMDocument->createAttribute()
DOMDocument->createAttributeNS()
DOMDocument->createCDATASection()
DOMDocument->createComment()
DOMDocument->createDocumentFragment()
DOMDocument->createElementNS()
DOMDocument->createEntityReference()
DOMDocument->createProcessingInstruction()
DOMDocument->createTextNode()

szkolenia dla księgowych kursy księgowe księgowość
Solidnie i tanio przeprowadzki kraków transport mebli, profesjonalnie
kalkulator kredytu hipotecznego
Prawo jazdy Szczecin
Oryginalne perfumy w promocyjnych cenach

Another Useful functions:


function.dom-domxpath-registernamespace | function.dom-domxpath-query | function.dom-domxpath-evaluate | function.dom-domxpath-construct | function.dom-domtext-splittext | function.dom-domtext-iswhitespaceinelementcontent | function.dom-domtext-construct | function.dom-domprocessinginstruction-construct | function.dom-domnodelist-item | function.dom-domnode-replacechild | function.dom-domnode-removechild | function.dom-domnode-normalize | function.dom-domnode-lookupprefix | function.dom-domnode-lookupnamespaceuri | function.dom-domnode-issupported | function.dom-domnode-issamenode | function.dom-domnode-isdefaultnamespace | function.dom-domnode-insertbefore | function.dom-domnode-haschildnodes | function.dom-domnode-hasattributes | function.dom-domnode-clonenode | function.dom-domnode-appendchild | function.dom-domnamednodemap-item | function.dom-domnamednodemap-getnameditemns | function.dom-domnamednodemap-getnameditem | function.dom-domimplementation-hasfeature | function.dom-domimplementation-createdocumenttype | function.dom-domimplementation-createdocument | function.dom-domimplementation-construct | function.dom-domentityreference-construct | function.dom-domelement-setidattributens | function.dom-domelement-setidattributenode | function.dom-domelement-setidattribute | function.dom-domelement-setattributens | function.dom-domelement-setattributenodens | function.dom-domelement-setattributenode | function.dom-domelement-setattribute | function.dom-domelement-removeattributens | function.dom-domelement-removeattributenode | function.dom-domelement-removeattribute | function.dom-domelement-hasattributens | function.dom-domelement-hasattribute | function.dom-domelement-getelementsbytagnamens | function.dom-domelement-getelementsbytagname | function.dom-domelement-getattributens | function.dom-domelement-getattributenodens | function.dom-domelement-getattributenode | function.dom-domelement-getattribute | function.dom-domelement-construct | function.dom-domdocumentfragment-appendxml | function.dom-domdocument-xinclude | function.dom-domdocument-validate | function.dom-domdocument-schemavalidatesource | function.dom-domdocument-schemavalidate | function.dom-domdocument-savexml | function.dom-domdocument-savehtmlfile | function.dom-domdocument-savehtml | function.dom-domdocument-save | function.dom-domdocument-relaxngvalidatesource | function.dom-domdocument-relaxngvalidate | function.dom-domdocument-registernodeclass | function.dom-domdocument-normalizedocument | function.dom-domdocument-loadxml | function.dom-domdocument-loadhtmlfile | function.dom-domdocument-loadhtml | function.dom-domdocument-load | function.dom-domdocument-importnode | function.dom-domdocument-getelementsbytagnamens | function.dom-domdocument-getelementsbytagname | function.dom-domdocument-getelementbyid | function.dom-domdocument-createtextnode | function.dom-domdocument-createprocessinginstruction | function.dom-domdocument-createentityreference | function.dom-domdocument-createelementns | function.dom-domdocument-createelement | function.dom-domdocument-createdocumentfragment | function.dom-domdocument-createcomment | function.dom-domdocument-createcdatasection | function.dom-domdocument-createattributens | function.dom-domdocument-createattribute | function.dom-domdocument-construct | function.dom-domcomment-construct | function.dom-domcharacterdata-substringdata | function.dom-domcharacterdata-replacedata | function.dom-domcharacterdata-insertdata | function.dom-domcharacterdata-deletedata | function.dom-domcharacterdata-appenddata | function.dom-domattr-isid | function.dom-domattr-construct |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.