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
mg']->node(0); You can download Raxan here: http://raxanpdi.com/downloads.html __ Raymond Irving --- On Sat, 8/22/09, Manuel Lemos wrote: From: Manuel Lemos Subject: [PHP] Re: How do I extract link text from anchor tag as well as the URL from the "href" attribute To: "chr

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

2009-08-21 Thread Manuel Lemos
Hello, on 08/16/2009 04:33 AM chrysanhy said the following: > I have the following code to extract the URLs from the anchor tags of an > HTML page: > > $html = new DOMDocument(); > $htmlpage->loadHtmlFile($location); > $xpath = new DOMXPath($htmlpage); > $links = $xpath->query( '//a' ); > foreach

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

[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
did u try it something like this foreach ($links as $link) { $int_url_list[$i]["href"] = $link->getAttribute( 'href' ); $int_url_list[$i++]["linkText"] = $link->getContent( ); // nodeValue(); } that should work send ur code then please ralph_def...@yahoo,de "chrysanhy" wrote in messag

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

[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
try $link->nodeValue() or $link->getContent() im not shure which one works on an image link which is indeed a child of wrote in message news:88827b190908160033n226b370bqe2ab70732811...@mail.gmail.com... > I have the following code to extract the URLs from the anchor tags of an > HTML page: >