PHP: DomElement->getAttribute

前端 未结 4 573
失恋的感觉
失恋的感觉 2020-12-04 01:52

How can I take all the attribute of an element? Like on my example below I can only get one at a time, I want to pull out all of the anchor tag\'s attribute.



        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 02:29

    $a = $dom->getElementsByTagName("a");
    foreach($a as $element)
    {
       echo $element->getAttribute('href');
    }
    

提交回复
热议问题