DOM i wyciąganie src obrazka będącego anchorem linku

0

W zasadzie, to jak w temacie, bo już nie ogarniam tych obiektów DOM...

Mam klasę, której jedna z metod wygląda tak:

function crawlLinks($url)

	{

		$content=$this->getContent($url);
		$domain=$this->getDomain($url);

		$dom = new DOMDocument();

		@$dom->loadHTML($content);		

		$xpath = new DOMXPath($dom);

		$hrefs = $xpath->evaluate("//a");
		

		for ($i = 0; $i < $hrefs->length; $i++) 

		{

			$href = $hrefs->item($i);//select an a tag									

			$links['link'][$i]=$href->getAttribute('href');

			$links['text'][$i]=$href->nodeValue;

			$links['title'][$i]=$href->getAttribute('title');
		}

		return  $links;

Kombinuję już kilka godzin i googluję i nie mogę znaleźć, jak wyciągnąć z mojego elementu w pętli for src obrazka, który zdarza się być anchorem. nodeValue wyrzuca pustkę.
Po prostu nie ogarniam tego DOM, jeśli znalazłby się ktoś na tyle uprzejmy i chociaż dał jakieś światło na rozwiązanie tego, będzie super...

0

Temat rozwiązany, oto poprawiony fragment kodu:

$xpath = new DOMXPath($dom);
		$hrefs = $xpath->evaluate("//a");//get all a tags	
		
		for ($i = 0; $i < $hrefs->length; $i++) 
		{
			$href = $hrefs->item($i);//select an a tag									
			$links['link'][$i]=$href->getAttribute('href');
			$links['text'][$i]=$href->nodeValue;
			$child = $href->firstChild;
			$links['title'][$i]=$child->getAttribute('src');//$href->getAttribute('title');
		}

1 użytkowników online, w tym zalogowanych: 0, gości: 1