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 9060145
In Process

The Archive Base Latest Questions

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

i need to parse html like : <div class=item><div class=title>title 1</div><div class=date>day 1</div></div> <div

  • 0

i need to parse html like :

<div class="item"><div class="title">title 1</div><div class="date">day 1</div></div>
<div class="item"><div class="title">title 2</div><div class="date">day 2</div></div>
<div class="item"><div class="title">title 3</div><div class="date">day 3</div></div>

Actually i do something like this :

$title = $xpath->query('//div[@class="title"]//text()');
foreach ($title as $title)
{
  $title = trim($title->nodeValue);
}

$date = $xpath->query('//div[@class="date"]//text()');
foreach ($date as $date)
{
  $date = trim($date->nodeValue);
}

But with this i take only one item, so i looking for the proper way to get all the items in the same while.

  • 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-16T15:08:59+00:00Added an answer on June 16, 2026 at 3:08 pm

    You probably want to loop over the item elements, then find their respective title and date text.

    $items = $xpath->query('//div[@class="item"]');
    foreach ($items as $item) {
        $title = $xpath->evaluate('string(div[@class="title"])', $item);
        $date  = $xpath->evaluate('string(div[@class="date"])', $item);
        echo "$title $date\n";
    }
    

    » See the above example running online.

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

Sidebar

Related Questions

Using Jericho, I need to parse something like this: <html> <div class=title> Spoon bows
I need to parse an HTML file and i've got something like this: <TAG1>
I'm trying to parse strings that represent source code, something like this: [code lang=html]
Is there anything like Jsoup but instead of parsing HTML, I need to parse
I need to parse through a CMS generated HTML page and add list item
I have this tag into my html file: {{block:my_test_block}} {{news:my_test_block2}} I need to parse
I have this piece of HTML: <div class=embed> <iframe width=300 height=200 frameborder=0 allowfullscreen= src=http://www.youtube.com/embed/123456></iframe>
I've got div like this : <div id=something-1 data-options='{pause:YES,delete:NO, kill:NO}'></div> What I got going
I have this string containing a date I need to parse to get a
I have this html data which I need to parse to extract data from

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.