downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DOMDocumentType> <DOMDocumentFragment
[edit] Last updated: Fri, 23 Mar 2012

view this page in

DOMDocumentFragment::appendXML

(PHP 5 >= 5.1.0)

DOMDocumentFragment::appendXMLHam bir XML verisi ekler

Açıklama

bool DOMDocumentFragment::appendXML ( string $veri )

Bir DOMDocumentFragment nesnesine ham bir XML verisi ekler.

Bu yöntem DOM standardının bir parçası değildir. Bir DOMDocument nesnesine bir XML belge parçası eklemek için basit bir yaklaşım olarak gerçeklenmiştir.

Standardla tam uyum içinde olmak isterseniz, sahte bir kök elemana sahip geçici bir DOMDocument oluşturup XML verinizi ekleyeceğiniz kök elemanın çocuk düğümleriyle bir döngüye girmelisiniz.

Değiştirgeler

veri

Eklenecek XML veri.

Dönen Değerler

Başarı durumunda TRUE, başarısızlık durumunda FALSE döner.

Örnekler

Örnek 1 - Belgeye XML veri eklemek

<?php
$doc 
= new DOMDocument();
$doc->loadXML("<root/>");
$f $doc->createDocumentFragment();
$f->appendXML("<foo>text</foo><bar>text2</bar>");
$doc->documentElement->appendChild($f);
echo 
$doc->saveXML();
?>

Yukarıdaki örneğin çıktısı:

<?xml version="1.0"?>
<root><foo>text</foo><bar>text2</bar></root>



add a note add a note User Contributed Notes DOMDocumentFragment::appendXML
lpetrov(AT)axisvista.com 20-Jul-2007 05:45
Here is (maybe) a better example:
/**
* Helper function for replacing $node (DOMNode)
* with an XML code (string)
*
* @var DOMNode $node
* @var string $xml
*/
public function replaceNodeXML(&$node,$xml) {
 $f = $this->dom->createDocumentFragment();
 $f->appendXML($xml);
 $node->parentNode->replaceChild($f,$node);
}

Copied from the "PHP5 Dom Based Template" article at:
http://blog.axisvista.com/?p=35

 
show source | credits | sitemap | contact | advertising | mirror sites