This question already has an answer here:
I know understand that it's not advised to using regular expressions to parse HTML. I'm using the following regex to get the data inside of a element that comes directly after a element.
$string = "</th><td>Capture This</td>";
$pattern = "/<\/th>.*<td>(.*)<\/td>$/";
preg_match ($pattern, $string, $matches);
echo("<pre>" . $matches[0] . "</pre>");
Can somebody please explain to me how I'd go about capturing the contents of a <td>
element that comes directly after the closing tag of a <th>
element using PHP's DOMDocument or similar functionality?
</div>
It can easily be fetched with Simple HTML DOM for PHP:
http://simplehtmldom.sourceforge.net/
Post some more of the source and I will give you the element path