CakeFest 2024: The Official CakePHP Conference

DOMElement::__construct

(PHP 5, PHP 7, PHP 8)

DOMElement::__constructYeni bir DOMElement nesnesi oluşturur

Açıklama

public DOMElement::__construct(string $qualifiedName, ?string $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.

Bağımsız Değişkenler

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

User Contributed Notes 1 note

up
3
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
To Top