children() 函数获取指定节点的子节点。
class SimpleXMLElement { string children(ns,is_prefix) }
参数 | 描述 |
---|---|
ns | 可选。 |
is_prefix | 可选。默认是 false。 |
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
PHP 代码:
<?php
$xml = simplexml_load_file("test.xml");
foreach ($xml->children()
as $child)
{
echo "Child node: " . $child;
}
?>
输出类似:
Child node: George Child node: John Child node: Reminder Child node: Don't forget the meeting!
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号