I am trying to parse a tabular structured data from a html page..
It has the following structure
<table>
<tr>
<td><a href="url">name</a></td>
<td>Lakeside</td>
<td>California</td>
<td>92040</td>
<td>United States</td>
<td>Off Road</td>
</tr>
</table>
I am trying this,
$dom = new DOMDocument;
$url = "url";
@$dom->loadHTMLFile($url);
$xpath = new DOMXpath($dom);
$xNodes = $xpath->query("//td");
foreach ($xNodes as $xNode)
{
$sLinktext = @$xNode->firstChild->data;
echo $sLinktext."<br/>";
$sLinkurl = $xNode->getAttribute('a');
if ($sLinktext != '' && $sLinkurl != '')
{
echo '<li><a href="' . $sLinkurl . '">' . $sLinktext . '</a></li>';
}
}
It is returning only td data but it is not showing me the a href data..
UPDATE
How can go to next level, I mean, i have an anchor tag. If i click on it i will be redirected to another page, and that page contains the detailed information of a place. I just want to get that information to be parsed along with these details. Is it possible to Parse multiple pages at one go
Please guide me. Thank you