Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top