فونکشن children() PHP

تعریف و استفاده

فونکشن 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!