I Need Help With Php Dom ? Need A Little Change In My Code?

Started on the old forum in July 2008 · view the original in the archive · old links redirect here

1 reply · 384 views · started 18 years ago · 1 min read

Guest #1

i want to echo all the linkname and their urls i got the code below for the url ,just dont know how to get the link name...?

$dom = new DOMDocument();
@$dom->loadHTML($content);

$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");

for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo "
Link stored: $url";

//// i tried this//// $linkname=$href->getAttribute('name');
///echo"$linkname 
";
}

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close