So far, my code is getting all classes 'forumRow' using a xPath query. How would I get the href-attribute of the a-element which exists once in every 'forumRow' class?
I'm kinda stuck at the point where I can run a query starting from the result of the first query.
My current code
$this -> boards = array();
$html = @file_get_contents('http://www.roblox.com/Forum/Default.aspx');
libxml_use_internal_errors(true);
$page = new DOMDocument();
$page -> preserveWhiteSpace = false;
$page -> loadHTML($html);
$xpath = new DomXPath($page);
$board_array = $xpath -> query('//*[@class="forumRow"]');
foreach($board_array as $board)
{
$childNodes = $board -> childNodes;
$boardName = $childNodes -> item(0) -> nodeValue;
if (strlen($boardName) > 0)
{
$boardDesc = $childNodes -> item(1) -> nodeValue;
array_push($this -> boards, array($boardName, $boardDesc));
}
}
$Cache -> saveData(json_encode($this -> boards));