How should we parse HTML in PHP?

Submitted by: Muhammad
What exactly is meant by the sentence "For a complex resource such as an HTML document, the script would need
to parse it to find references to embedded, included resources:
javascript files, CSS files, iframes, etc."?

Well, as you probably know, an HTML page often uses other files to render the HTML page - like CSS file(s) for styling, Javascript file(s) for adding more functionality to the HTML page, and so on. But the question is how do we take an HTML page and find all of those resources in the HTML page. Of course, this is easy to do if we are reading the HTML page with the human eye. But, we want to find these resources using a program that will read the HTML for us. This is actually more complicated than it seems - and the process by which a program (like PHP) reads an HTML file and analyzes the text to extract meaningful data (like resources) is known as parsing the HTML. Any text can be parsed, but we are exclusively focused on HTML for the purpose of this interview question.
Submitted by: Muhammad

Read Online Sr. PHP Programmer Job Interview Questions And Answers