Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:41:08+00:00 2026-06-10T15:41:08+00:00

Possible Duplicate: read XML tag id from php what is the way to fetch

  • 0

Possible Duplicate:
read XML tag id from php

what is the way to fetch data from A Specific div id Using PHP. What i want to do is to fetch data from a div id called <div id="content"> , so all the data from that div id will be fetched in a variable.
I can fetch all content with my script but cant filter it to fetch data from a Specific div tag.
Here is the script i am using to fetch any content:

function file_get_contents_curl($url)
{
$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$data = curl_exec($ch);
curl_close($ch);

return $data;
}
$html = file_get_contents_curl("http://www.example.com");
//parsing all content:
$doc = new DOMDocument();
@$doc->loadHTML($html);
echo "$html";

any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:41:10+00:00Added an answer on June 10, 2026 at 3:41 pm

    Try this but make sure you have downloaded and included PHP Simple HTML DOM Parser

    $html = file_get_html("http://www.example.com");
    $displaybody = $html->find('div[id=content]', 0)->plaintext;
    

    Their are some ways to exclude content from div id or Tag id like,

    1) Using regex

    2) Using SimpleXML

    3) With DOM extension Or XPath

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: File to byte[] in Java I want to read data from file
Possible Duplicate: I want to load the data from XML file and show in
Possible Duplicate: how to read a xml file using java? I want to the
Possible Duplicate: C#: Read XML Attribute using XmlDocument In C# if I were to
Possible Duplicate: How to read XML response from a URL in java? I'm trying
Possible Duplicate: Use LINQ to read all nodes from XML I am trying to
Possible Duplicate: read/write to Windows Registry using Java I want to read the registry
Possible Duplicate: Can PHP read the hash portion of the URL? Hi, I want
Possible Duplicate: how to read images from xml file? how to get images from
Possible Duplicate: Read pdf files with php Can you read PDF files by using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.