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
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 ($links
try
$link-nodeValue()
or
$link-getContent()
im not shure which one works on an image link which is indeed a child of a
so u could also check if the node has a child, if so its an image with, in
good practice. an alt attribute to use
haven't tried but should work. let me know pls
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 ralph_def...@yahoo.de wrote:
try
$link-nodeValue()
or
$link-getContent()
im not shure which one works on an image link which is indeed a child of a
so u could also check
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
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 =EOB
well the immage goes inside the a.. img... /a
on ur html the node a has no value however u should not get a error
this is pergect jtml link
a href=thema.htmimg src=button4.jpg width=160 height=34
border=0 alt=THEMA/a
ralph
chrysanhy phpli...@hyphusonline.com wrote in message
this worked here:
?php
$html = new DOMDocument();
$html-loadHtmlFile(testHtml.html);
$links = $html-getElementsByTagName('a');
echo pre;
foreach ($links as $item) {
echo $item-getAttribute( 'href' ). \n;
echo --- . $item-nodeValue . \n;
}
echo /pre;
?
Im sending u the 2 files directly
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 ralph_def...@yahoo.dewrote:
this worked here:
?php
$html = new DOMDocument();
$html-loadHtmlFile(testHtml.html);
$links = $html-getElementsByTagName('a');
9 matches
Mail list logo