How do I extract this value using PHP Dom

Posted by mathew on Stack Overflow See other posts from Stack Overflow or by mathew
Published on 2011-01-03T18:39:28Z Indexed on 2011/01/03 18:53 UTC
Read the original article Hit count: 210

Filed under:
|
|

Hello

I do have html file this is just a prt of it though...

<div id="result" >
    <div class="res_item" id="1" h="63c2c439b62a096eb3387f88465d36d0">
        <div class="res_main">
            <h2 class="res_main_top">
                <img 
                    src="/ff/gigablast.com.png" 
                    alt="favicon for gigablast.com" 
                    width=16 
                    height=16
                    />&nbsp;
                <a 
                    href="http://www.gigablast.com/" 
                    rel="nofollow"
                    >
                    Gigablast
                </a>
                <div class="res_main">
                    <h2 class="res_main_top">
                        <img 
                            src="/ff/ask.com.png" 
                            alt="favicon for ask.com" 
                            width=16 
                            height=16
                            />&nbsp;
                        <a 
                            href="http://ask.com/" rel="nofollow"
                            >
                            Ask.com - What&#039;s Your Question?
                        </a>....

I want extract only url address (for example: http://www.gigablast.com and http://ask.com/ - there are atleast 10 urls in that html) from above using PHP Dom Document..I know up to this but dont know how to move ahead??

$doc = new DomDocument;
$doc->loadHTMLFile('urllist.html');

$data = $doc->getElementById('result');

then what?? this is inside tag hence I cant use $data->getElementsByTagName() here!!

any help??

© Stack Overflow or respective owner

Related posts about php

Related posts about php5