现有的php代码输出xml节点时,只能输出第一个同名节点内容"100". 请问怎样才能输出所有节点的内容呢?
现有代码:
/* $xmlstring 原内容:
-
*/
$xmldoc = new DOMDocument();
$xmldoc->loadXML($xmlstring);
$users = $xmldoc->getElementsByTagName('GetUserInfo');
foreach ($users as $user) {
<code>$html .= 'outputCustomer:'.get_txt($user,'Customer').'<br />'; $html .= 'outputGeo:'.get_txt($user,'GeocallCLI').'<br />';</code>
}
echo $html;
function get_txt($parent, $name) {
<code>$nodes = $parent->getElementsByTagName($name); return $nodes->item(0)->nodeValue;</code>
}
?>
另问怎样只输出
现有的php代码输出xml节点时,只能输出第一个同名节点内容"100". 请问怎样才能输出所有节点的内容呢?
现有代码:
/* $xmlstring 原内容:
-
*/
$xmldoc = new DOMDocument();
$xmldoc->loadXML($xmlstring);
$users = $xmldoc->getElementsByTagName('GetUserInfo');
foreach ($users as $user) {
<code>$html .= 'outputCustomer:'.get_txt($user,'Customer').'<br />'; $html .= 'outputGeo:'.get_txt($user,'GeocallCLI').'<br />';</code>
}
echo $html;
function get_txt($parent, $name) {
<code>$nodes = $parent->getElementsByTagName($name); return $nodes->item(0)->nodeValue;</code>
}
?>
另问怎样只输出
自己顶上, 哪位大侠能解答下么
我顶
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号