Possible duplicate:
How to parse and process HTML using PHP?
Suggestion for reference . There are dozens of "How to parse HTML" questions that appear every day. However, it is very difficult to close as a duplicate, because most of the questions relate to the specific scenario presented by the appellant. This question is an attempt to build a general "reference question" that covers all aspects of the problem.
This is an experiment. If such a reference question already exists, let me know and I will gladly delete this one.
My ideal vision is that each of the three questions gets an answer separately, and the best answers for each bubble up.
I will award 200 bounties with the best answer in each of the three categories in two weeks, pending discussion of this issue on Meta strong>.
Each of these questions has already received a brilliant answer elsewhere, so copying + pasting my own answer to another question is fine with me.
How to parse HTML using PHP?
What libraries exist? Which ones use the PHP DOM, which have their own parsing engine? (Hint: SimpleHTMLDOM)
1a. I need to find a specific item, but it's hard for me to get used to the XPath syntax. Are there any DOM-based libraries that simplify HTML parsing? Please consider creating common examples in the real world.
Is there a PHP library that allows me to query the DOM using CSS [2/3] selectors like jQuery? (Hint: phpQuery). Please consider creating common examples in the real world.
Bonus question: why shouldn't I use regular expressions? Please provide a very short answer in layman's terms.
html php regex html-parsing
Pekka 웃 Sep 06 2018-10-10T00: 00Z
source share