// Find all element has attribute id
$ret = $html->find('*[id]');
This is an example for finding all elements which have attribute id. Is there any way to find all elements. I try this way but it does not work:
// Find all element
$ret = $html->find('*');
additional:
I want to fetch through all the elements in $html, all parents and childs elements will be fetched. Example:
<div>
<span>
<div>World!</div>
<div>
<span>Hello!</span>
<span>
<div>Hello World!</div>
</span>
</div>
</span>
</div>
Now I want to escape all <span>
with their plaintext inside and keep all <div>
we have! Expected result:
<div>
<div>World!</div>
<div>
<div>Hello World!</div>
</div>
</div>
This is my solution, I made it, I just post here if someone need it and end this question.
Note that: this function uses recursive. So, too large data will be a big problem. Reconsider carefully when decide to use this function.