質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top