douren1928 2010-07-12 20:58
浏览 24
已采纳

如何从特定类的锚标记中获取href

If I have an HTML document, what is the best way to go through the document and gather the href values from all anchor tags with a particular class using PHP?

  • 写回答

1条回答 默认 最新

  • dtwk6019 2010-07-12 21:19
    关注

    See soulmerge's answer to "Preg_match_all href". Adjust the XPath to

    //a[@class="foo"]/@href
    

    to get a DOMNodeList of all href attributes belonging to elements with a class of foo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?