How can the parent node be properly considered when using xpath to query specific elements within a table in PHP?

When using XPath to query specific elements within a table in PHP, it is important to consider the parent node of the elements you are trying to select. This is because XPath queries are relative to the context node, which is typically the parent node of the elements you are interested in. To properly consider the parent node, you can use the `//` operator to select elements regardless of their position in the document tree.

// Load the HTML content into a DOMDocument
$html = '<table><tr><td>Row 1, Column 1</td><td>Row 1, Column 2</td></tr><tr><td>Row 2, Column 1</td><td>Row 2, Column 2</td></tr></table>';
$dom = new DOMDocument();
$dom->loadHTML($html);

// Create a DOMXPath object to query the document
$xpath = new DOMXPath($dom);

// Query for all td elements within the table
$tdNodes = $xpath->query('//table//td');

// Loop through the selected td elements and output their content
foreach ($tdNodes as $tdNode) {
    echo $tdNode->nodeValue . PHP_EOL;
}