//子節(jié)點 $one = $root->new_child("question", ""); //為子節(jié)點設置屬性 $one->setattr("number", "1"); //question也創(chuàng)建子節(jié)點,并且給它賦值 $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?" ); // 創(chuàng)建一個不直接賦值的節(jié)點 $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." );