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

search for in the

DomNode->attributes> <DomNode->append_child
Last updated: Fri, 04 Jul 2008

view this page in

DomNode->append_sibling

(No version information available, might be only in CVS)

DomNode->append_sibling — Agrega un nuevo hermano a un nodo

Descripción

domelement DomNode->append_sibling ( domelement $nodo_nuevo )

Esta función agrega un hermano a un nodo existente. El hijo puede ser creado, por ejemplo, con domdocument_create_element(), domdocument_create_text() etc. o simplemente mediante el uso de otro nodo.

Antes de que un nuevo hermano sea agregado, éste es duplicado. Por lo tanto, el nuevo hijo es una copia completamente nueva que puede modificarse sin cambiar el nodo que fue pasado a ésta función. Si el nodo pasado tiene hijos, ellos serán duplicados también, lo que facilita enormemente la duplicación de partes grandes de un documento XML. El valor de retorno es el hermano agregado. Si planea hacer modificaciones posteriores al hermano agregado, debe usar el nodo devuelto.

Esta función ha sido agregada para ofrecer el comportamiento de domnode_append_child(), del modo que funcionaba hasta PHP 4.2.

Vea también domnode_append_before().



add a note add a note User Contributed Notes
DomNode->append_sibling
s dot girard at pandora dot be
01-May-2004 08:06
Small example on the use of domnode->append_sibling()
This function creates a news.xml file, that will be later on parsed with XSLT.

$doc = domxml_new_doc("1.0");
$root = $doc->create_element("rt");
$root = $doc->append_child($root);
$page = $doc->create_element("page");
$page = $root->append_child($page);
$page->set_attribute("pageimage","images/news.jpg");
   
while($row = mysql_fetch_row($result))
{
    $news = $doc->create_element("news");
    $news = $page->append_child($news);
       
    $topic = $doc->create_element("topic");
    $topic = $news->append_child($topic);
       
    $topic_content = $doc->create_text_node($row[0]);
    $topic_content = $topic->append_child($topic_content);
       
    $user = $doc->create_element("user");
    $user = $topic->append_sibling($user);
   
    $user_content = $doc->create_text_node($row[3]);
    $user_content = $user->append_child($user_content);
       
    $date = $doc->create_element("date");
    $date = $topic->append_sibling($date);
       
    $date_content = $doc->create_text_node($row[2]);
    $date_content = $date->append_child($date_content);
       
    $body = $doc->create_element("body");
    $body = $topic->append_sibling($body);
       
             $body_content = $doc->create_text_node($row[1]);
    $body_content = $body->append_child($body_content);
}
unlink("./data/news.xml");
$doc->dump_file("./data/news.xml");

DomNode->attributes> <DomNode->append_child
Last updated: Fri, 04 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites