I have opened an HTML file using
file_get_contents('http://www.example.com/file.html')
and want to parse the line including "ParseThis":
<h1 class=\"header\">ParseThis<\/h1>
As you can see, it's within an h1
tag (the first h1
tag from the file). How can I get the text "ParseThis"?
You can use DOM for this.
Also see
Marking this CW because I have answered this before, but I am too lazy to find the duplicate
Use this function.
Since it is the first h1 tag, getting it should be fairly trivial:
http://php.net/manual/en/class.domdocument.php