pankaj shukla - 2009-02-10 16:58:43
I am trying to extract all the links ("a" tags) and storing href and anchor text(raw text between the <a> and </a> tags) into Database.
I am having no problem doing this until the contents are an image.
HTML file contains code like following line in many places -
<a href="http://example.com"><img src="example.gif"></a>
My code o
I am using DOM objects but unable to access it.
My code is like -
--------------------
$dom = new DOMDocument();
@$dom->loadHTML($input);
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("//a");//get all a tags
for ($i = 0; $i < $hrefs->length; $i++)
{
$href = $hrefs->item($i);
$links['link'][$i]=$href->getAttribute('href');
$links['text'][$i]=$href->nodeValue;
}
$dom->save('test.html');
--------------------
If anyone has any idea/suggestion, please share it...
Thanks in advance
- Pankaj