时间:2021-07-01 10:21:17 帮助过:23人阅读
1. contacts.xml代码
代码如下:
2. php代码
代码如下:<?php
$tel_node = null;
$doc = xmldocfile ('contacts.xml');
$contact_node = $doc->root ();
$kids = $contact_node->children ();
while ($node = array_shift ($kids)) {
if (($node->type == XML_ELEMENT_NODE) && ($node->tagname == 'personal')) {
$tel_node =& $node;
break;
}
}
if ($tel_node == null){
die ("Couldn't locate 'personal' node.");
}
$work_node = $tel_node->new_child ('work', '6666');
print ("
\n");\n");
print (htmlspecialchars ($doc->dumpmem ()));
print ("
希望本文所述对大家的php程序设计有所帮助。