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?