沒關係:我找到了,程式碼如下
<?php
if($element->hasAttributes())
{
$attributes = $element->attributes;
if(!is_null($attributes))
{
foreach ($attributes as $index=>$attr)
{
echo $attr->name."=\"".$attr->value."\"";
}
}
}
?>
(PHP 5, PHP 7, PHP 8)
DOMNamedNodeMap::item — 擷取指定索引的節點
index
此映射中的索引。
映射中第 index
個位置的節點,如果該索引無效(大於或等於此映射中的節點數),則返回 null
。
沒關係:我找到了,程式碼如下
<?php
if($element->hasAttributes())
{
$attributes = $element->attributes;
if(!is_null($attributes))
{
foreach ($attributes as $index=>$attr)
{
echo $attr->name."=\"".$attr->value."\"";
}
}
}
?>