Export particular element in DOMDocument to string

前端 未结 3 1650
一个人的身影
一个人的身影 2021-01-18 01:34

I\'m importing some arbitrary HTML into a DOMDocument using the loadHTML() function, eg.:

$html = \'

3条回答
  •  情话喂你
    2021-01-18 02:21

    Thanks but I won't necessarily know the type of the first tag in the body, it needs to be generic

    $domnodelist = $doc->getElementsByTagName('*');
    $domnode = $domnodelist->item(0);
    echo $doc->saveXML($domnode);
    

提交回复
热议问题