Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-22 Thread Raymond Irving
Hello, You might also want to try using the Raxan framework: require_once 'raxan/pdi/gateway.php'; $page = new RichWebPage('page.html'); echo $page['a']->text(); // this will get the text betwen the a tag   To get the image element use: $elm = $page['a img']->node(0); You can download Raxan he

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread chrysanhy
The code snippet below worked! Thank you so much for your time helping me with this! On Sun, Aug 16, 2009 at 11:26 AM, Ralph Deffke wrote: > this worked here: > > $html = new DOMDocument(); > $html->loadHtmlFile("testHtml.html"); > $links = $html->getElementsByTagName('a'); > echo ""; > > foreac

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread Ralph Deffke
this worked here: loadHtmlFile("testHtml.html"); $links = $html->getElementsByTagName('a'); echo ""; foreach ($links as $item) { echo $item->getAttribute( 'href' ). "\n"; echo "---" . $item->nodeValue . "\n"; } echo ""; ?> Im sending u the 2 files directly in a minute. it came out, as I

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread Ralph Deffke
well the immage goes inside the on ur html the node a has no value however u should not get a error this is pergect jtml link ralph "chrysanhy" wrote in message news:88827b190908160943t2254137fve43771c7e4f8c...@mail.gmail.com... > WHile waiting for suggestions for extracting the link text

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread chrysanhy
WHile waiting for suggestions for extracting the link text from the DOM, I tried a brute force approach using the URLs I had found with getAttribute(), but found myself baffled by my results. I boiled down my issue with this approach to the following snippet. $htmldata =<

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread chrysanhy
I pasted the code exactly as you have it, and I got the following: *Fatal error*: Call to undefined method DOMElement::getContent() I got the same thing with nodeValue(). On Sun, Aug 16, 2009 at 7:35 AM, Ralph Deffke wrote: > did u try it something like this > > foreach ($links as $link) { >

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread Ralph Deffke
I found this iteration over the item collection for ($i = 0; $i < $items->length; $i++) { echo $items->item($i)->nodeValue . "\n"; } check here as well http://us.php.net/manual/en/domnodelist.item.php doesn't seem a simple foreach dos it ralph_def...@yahoo.de "chrysanhy" wrote in message n

Re: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute

2009-08-16 Thread chrysanhy
It did not work. Both gave me a "Call to undefined method" fatal error. On Sun, Aug 16, 2009 at 1:43 AM, Ralph Deffke wrote: > > try > > $link->nodeValue() > > or > > $link->getContent() > > im not shure which one works on an image link which is indeed a child of so u could also check if the no