如何从特定类别的锚标记中获取href [英] How to get href from anchor tag with particular class
本文介绍了如何从特定类别的锚标记中获取href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有HTML文档,最好的浏览文档的最佳方法是使用PHP从具有特定类的所有锚标签中收集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?
推荐答案
请参见 soulmerge对"Preg_match_all href"的回答.将XPath调整为
See soulmerge's answer to "Preg_match_all href". Adjust the XPath to
//a[@class="foo"]/@href
获取所有href属性的DOMNodeList,这些属性属于具有foo
类的元素.
to get a DOMNodeList of all href attributes belonging to elements with a class of foo
.
这篇关于如何从特定类别的锚标记中获取href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文