PHP - 如何显示soap响应子子列表

I got a response in the following xml format like below: How can I get list->item->value in one row or container:

<list>
   <item>
    <Key>3</Key>
    <Value>3960</Value>
</item>
<item>
    <Key>5</Key>
    <Value>3967</Value>
</item>
<item>
    <Key>6</Key>
    <Value>3968</Value>
</item>
</list>

How can I display the value like this below

<table>
<tr>
<td>3960, 3967, 3968</td>
<td>3963, 3961, 3960</td>
</tr>
</table>

and at the moment I try to use children() in foreach, but it returns error: Call to a member function children() on null, and below is my php code

foreach($items as $item){

echo '<td>';
  $child_item = '';
  foreach($item->list->children()->children() as $child)
  {
    $child_item .= $child .' ,';
  }
  echo rtrim($child_item,' ,');
  echo  '</td>';

  }

Thanks experts!

This is what you need to achieve that:

<?php
$xmlstr = <<<XML
<root>
    <list>
        <item>
            <Key>3</Key>
            <Value>3960</Value>
        </item>
        <item>
            <Key>5</Key>
            <Value>3967</Value>
        </item>
        <item>
            <Key>6</Key>
            <Value>3968</Value>
        </item>
    </list>
    <list>
        <item>
            <Key>3</Key>
            <Value>3963</Value>
        </item>
        <item>
            <Key>5</Key>
            <Value>3961</Value>
        </item>
        <item>
            <Key>6</Key>
            <Value>3960</Value>
        </item>
    </list>
</root>
XML;

$items = new SimpleXMLElement($xmlstr);

echo "<table>
";
echo "<tr>
";
foreach($items as $list){
    echo "<td>";
    $itemsArr = array();
    foreach($list as $item){
        $itemsArr[] = $item->Value[0];
    }
    echo implode(", ", $itemsArr);
    echo "</td>
";
}
echo "</tr>
";
echo "</table>";
?>