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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:15:53+00:00 2026-06-01T05:15:53+00:00

I have the following HTML: […] <div class=row clearfix> <div class=col1>Data</div> <div class=col2>Data</div> <div

  • 0

I have the following HTML:

[...]
<div class="row clearfix">
    <div class="col1">Data</div>
    <div class="col2">Data</div>
    <div class="col3">Data</div>
    <div class="col4">Data</div>
    <div class="col5">Data</div>
    <div class="col6">Data</div>
    <div class="col7">Data</div>
    <div class="col8">Data</div>
</div><!--// row-->

<div class="row clearfix otherClass">
    <div class="col1">Data</div>
    <div class="col2">Data</div>
    <div class="col3">Data</div>
    <div class="col4">Data</div>
    <div class="col5">Data</div>
    <div class="col6">Data</div>
    <div class="col7">Data</div>
    <div class="col8">Data</div>
</div><!--// row-->

<div class="row clearfix thirdClass">
    <div class="col1">Data</div>
    <div class="col2">Data</div>
    <div class="col3">Data</div>
    <div class="col4">Data</div>
    <div class="col5">Data</div>
    <div class="col6">Data</div>
    <div class="col7">Data</div>
    <div class="col8">Data</div>
</div><!--// row-->
[...]

I want to get all of these divs out of the HTML, they all start with “row clearfix” as class, but can have more data to it.
After that I want to be able to handle each col separetely, so get the value of col1, col2, col3 ect.

I have written this code, but am stuck now. Can someone help me out?

        $oDom = new DOMDocument();
        $oDom->loadHtml($a_sHTML);

        $oDomXpath = new DOMXpath($oDom);
        $oDomObject = $oDomXpath->query('//div[@class="row clearfix"]');

        foreach ($oDomObject as $oObject) {
            var_dump($oObject->query('//div[@class="col1"]')->nodeValue);
        }

UPDATE *Solution*
Thanks to the replies below, I got it working with the following code:

    $oDom = new DOMDocument();
    @$oDom->loadHtml($a_sHTML);

    $oDomXpath = new DOMXpath($oDom);
    $oDomObject = $oDomXpath->query('//div[contains(@class,"row") and contains(@class,"clearfix")]');

    foreach ($oDomObject as $oObject) {
        foreach($oObject->childNodes as $col)
        {
            if ($col->hasAttributes())
            {
                var_dump($col->getAttribute('class') . " == " . trim($col->nodeValue));
            }
        }
    }
  • 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-01T05:15:55+00:00Added an answer on June 1, 2026 at 5:15 am

    To match the outer divs I think that what you need is

    //div[starts-with(@class,"row clearfix")]
    

    or

    //div[contains(@class,"row clearfix")]
    

    or

    //div[contains(@class,"row") and contains(@class,"clearfix")]
    

    I’d go for the last one because the class names could be in any order.

    I am not 100% sure what you want to do with the inner div, but you could get them with something like this:

    div[starts-with(@class,"col")]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following html: <div class=rows> <div class=row><input type=text onchange=javascript:getIndex(this); value= /></div> <div class=row><input
I have following HTML <div id=finalTree> <ul> <li class=last style=display: list-item;> <a id=DataSheets href=#>Data
I have the following HTML: <div class=tvShow align=left> <div class=clearfix style=margin:0px 0px;> <h3 class=left
i have following HTML structure: <div class=container> <div class=sidebar></div> <div class=content></div> <div class=subscript></div> </div>
I have following html: <div id=nav> <ul> <li class=keyitem>keyitem 1</li> <li>item</li> <li>item</li> <li>item</li> <li
I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a
I have following html snippet: <div class=rsw-pp rsw-pp-widget> <div g:type=AverageStarRating g:secondaryurls=http://maps.google.com/?cid=12948004443906002997 g:decorateusingsecondary=http://maps.google.com/?cid=12948004443906002997 g:groups=maps g:rating_override=2.998000
i have following html structure. <p class=expandableContent ><span class=label>Computer and Laptop Repairs</span></p> <div style=clear:
I have following html: <div id=note> <textarea id=textid class=textclass>Text</textarea> </div> How can I get
I have following HTML code: <div id=wrapper> <div class=page id=first> Test<br/> Test<br/> Test<br/> Test<br/>

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.