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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:57:44+00:00 2026-06-15T05:57:44+00:00

I am trying to convert this loaded DOM to an array format which I

  • 0

I am trying to convert this loaded DOM to an array format which I can use.

<div>
    <div>[a image]</div>
    <div>
        <p class="ab">text 1</p>
        <p class="bc">text 2</p>
    </div>
</div>
<div>
    <div>[a image]</div>
    <div>
        <p class="ab">text 1</p>
        <p class="bc">text 2</p>
    </div>
</div> 

I Would like to read these div nodes and convert it to an array structure like so:

var arrayObj = [{
“img” : “source”, “ab” : “text”, “bc” : “text” }, { “img” : “source”,
“ab” : “text”, “bc” : “text” }

Could someone please tell me how I can achieve this?

Thanks

  • 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-15T05:57:45+00:00Added an answer on June 15, 2026 at 5:57 am

    Loop through the container’s children[] array. For each one, find the image and the p tags. Assign to a new Object. Push the Object into an array.

    Example:

    var out = [], container = document.getElementById('container'),
        c = container.children, l = c.length, i, obj, p, m, j;
    for( i=0; i<l; i++) {
        obj = {};
        obj.img = c[i].getElementsByTagName('img')[0].src;
        p = c[i].getElementsByTagName('p');
        m = p.length;
        for( j=0; j<m; j++) obj[p[j].className] = p[j].firstChild.nodeValue;
        out[i] = obj;
    }
    // out
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert this line into Batch how would one start this exe
I'm trying to convert this string : $json = '[{a:1,b:2,c:3,d:4,e:5}, {a:6,b:7,c:8,d:9,e:10}]'; To an array
im trying to convert a date format into a new format in this example
This code returns a thumbnail of an image loaded from a byte array. I'm
I'm trying to convert an existing menu system which is loaded with inline Javascript
I am trying to convert one of my apps to now use Fragments. This
Trying to convert this c code into MIPS and run it in SPIM. int
I am trying to convert this to python. I just really need help with
I'm trying to convert this SQL query to L2S.. SELECT TOP 5 vt.* FROM
I'm trying to convert this SQL query to LINQ: SELECT Items.p_Name Product, DiamondCategory.dc_Name Category,

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.