how to fetch text nodes in DOM and PHP?

后端 未结 2 625
灰色年华
灰色年华 2021-01-22 12:42

I have the following code to retrieve all hyper links in an HTML document

and my question is how to retrieve the text nodes inside every anchor tag

(even if th

相关标签:
2条回答
  • 2021-01-22 13:02

    $anchor->textContent

    A slightly more info here DOMNode->textContent

    :D

    0 讨论(0)
  • 2021-01-22 13:19

    Heres what you can do:

    (string)$anchor->nodeValue;
    

    As referenced in the DomDocument::DomNode page

    0 讨论(0)
提交回复
热议问题