//子节点 $one = $root->new_child("question", ""); //为子节点设置属性 $one->setattr("number", "1"); //question也创建子节点,并且给它赋值 $one->new_child("text", "1. where to get libxml-2.0.0?"); $one->new_child("answer", "you can download the latest release of libxml either as a source archive or rpm package from http://www.xmlsoft.org. the current version is libxml2-2.2.1." );
$two = $root->new_child("question", "" ); $two->setattr("number", "2"); $two->new_child("text", "2. how to configure php4?" ); // 创建一个不直接赋值的节点 $twoone = $two->new_child("answer", ""); // 然后给它单独赋值 $twoone->set_content("dir is the libxml install directory (if you just use --with-dom it defaults to /usr), i needed to use --with-dom=/usr/local" );
$three = $root->new_child("question", "" ); $three->setattr("number", "7" ); $three->new_child("text", "7. how to use dom xml function ?" ); $three->new_child("answer", "read this document source for a simple example." );