Discover what element is using phpQuery()
-
30-04-2021 - |
質問
I am using phpQuery to parse every single element of HTML files, what I do is something like this:
foreach (pq('body')->children() as $children) {
// do some code here
}
However, I need to know which element is being parsed (table, div, p...).
How can I do this?
解決
Ok, I dit it. As phpQuery is based on DOMDocument I just had to use the attribute nodeName, like this:
foreach (pq('body')->children() as $children) {
echo $children->nodeName;
}
Perfectly works.
所属していません StackOverflow