View Single Post
Old 08-01-2009, 12:23 PM  
nation-x
Confirmed User
 
nation-x's Avatar
 
Industry Role:
Join Date: Mar 2004
Location: Rock Hill, SC
Posts: 5,370
Here is a way to do it without regex
Code:
$dom = new DOMDocument();
@$dom->loadHTML($html);

$xpath = new DOMXPath($dom);

$baseNodes = $xpath->evaluate("//base/@href");
if ($baseNodes->length == 1) {
	$baseUrl = rtrim($baseNodes->item(0)->nodeValue, '/');
}

$hrefs = $xpath->evaluate("//a");
nation-x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote