How to echo id from html content with Simple HTML Dom

9 Apr

Now,I will show you how you can echo id of any element from HTML code with the help of Simple HTML Dom.It can help you to scrape contents from websites.

Code :

<?php
include('simple_html_dom.php');

$html = "<a href='mailto:demo@demo.com' id='test-id'>Demo</a>";
$do = str_get_html($html);
foreach($do->find('a') as $e)
$item = $e->id;
echo $item;
$do->clear();
?>
Advertisements

2 Responses to “How to echo id from html content with Simple HTML Dom”

  1. germcode April 9, 2013 at 11:44 am #

    Hey make sure you put your code in pre tags!
    Orlando PHP development

  2. Admin April 9, 2013 at 12:36 pm #

    Its done,thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: