> PHP children() 函数

PHP children() 函数

定义和用法

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!
参考手册

W3c0.com 提供的内容仅用于培训。我们不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。W3c0 简体中文版的所有内容仅供测试,对任何法律问题及风险不承担任何责任。 当使用本站时,代表您已接受了本站的使用条款和隐私条款。版权所有,保留一切权利。 鲁ICP备15022115号