DOMElement::__construct

(PHP 5, PHP 7, PHP 8)

DOMElement::__constructYeni bir DOMElement nesnesi oluşturur

Açıklama

public DOMElement::__construct(string $qualifiedName, string|null $value = null, string $namespace = "")

Yeni bir DOMElement nesnesi oluşturur. Bu nesne salt okunurdur. Nesne bu haliyle bir belgeye eklenebilir, fakat belge ile ilişkilendirilinceye kadar yeni bir düğüm eklenemez. Yazılabilir bir düğüm oluşturmak için DOMDocument::createElement() veya DOMDocument::createElementNS() yöntemlerini kullanın.

Değiştirgeler

qualifiedName

Elemanın etiket ismi. Bir isim alanı betimleyicisi belirtildiği takdirde eleman ismi bu isim alanı ile ilişkili bir önek alabilir.

value

Elemanın değeri.

namespace

Elemanın bir isim alanına ait olması halinde bu isim alanını betimleyen adres.

Örnekler

Örnek 1 - Yeni bir DOMElement oluşturmak

<?php

$dom 
= new DOMDocument('1.0''utf-8');
$element $dom->appendChild(new DOMElement('kök'));
$element_ns = new DOMElement('bir:düğüm1''birdeğer''http://rst');
$element->appendChild($element_ns);
echo 
$dom->saveXML(); /* <?xml version="1.0" encoding="utf-8"?>
<kök><bir:düğüm1 xmlns:bu="http://rst">birdeğer</bir:düğüm1></kök> */

?>

Ayrıca Bakınız

add a note add a note

User Contributed Notes 3 notes

up
2
troelskn at gmail dot com
15 years ago
Note that this function is buggy. You have to manually escape the $value argument with htmlspecialchars.
See: http://bugs.php.net/bug.php?id=31191
up
-5
adar at darkpoetry dot de
17 years ago
If you like to view an element simply do:

<?php
echo htmlentities($element->C14N());
?>

Undocumented but found ;)
up
-9
Fabian dot Blech at gmx dot de
13 years ago
Remember, Dom-Nodes mustn't start with a number:

allowed:
<t12345t4>Value</t12345t4>

Not allowed:
<12345t4>VALUE</12345t4>
To Top