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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:30:26+00:00 2026-06-03T12:30:26+00:00

<ol id="author_list"> <li id="author_8"><div class="author">Author 1</div> <ol> <li class="affiliation_7"><div class="affiliation">School1</div> </li> <li class="affiliation_8"><div class="affiliation">School2</div>

  • 0
<ol id="author_list">
    <li id="author_8"><div class="author">Author 1</div>
        <ol>
            <li class="affiliation_7"><div class="affiliation">School1</div>
            </li>
            
            <li class="affiliation_8"><div class="affiliation">School2</div>
            </li>
        </ol>
    </li>
    <li id="author_10"><div class="author">Author 3</div>
        <ol>
            <li class="affiliation_7"><div class="affiliation">School1</div>
            </li>
        </ol>
    </li>
    <li id="author_9"><div class="author">Author 2</div>
        <ol>
            <li class="affiliation_8"><div class="affiliation">School2</div> 
            </li>
        </ol>
    </li>
</ol>

Which looks like this

enter image description here

I want to be able to loop through this list and store the exact position of the list in a json format so that I can reproduce the list in the same order later.

I’m not exactly sure how the json should look like but this is what I came up with. Not sure if this is the best way to store the data as well..

{
    "association1" : {
         "author": "author_8",
         "affiliation": {
             "affiliation_7": "0,0",
             "affiliation_8": "0,1"
         },
    "association2" : {
         "author": "author_10",
         "affiliation": {
             "affiliation_7": "1,0",
         },
    "association3" : {
         "author": "author_9",
         "affiliation": {
             "affiliation_8": "2,0",
         },       
}

My code so far

var indexList = [];
var level2 = $('#author_list li ol li')

level2.each(function() {
    var topIndex = $(this).index();
    var subIndex = $(this).parent().parent().index();
    indexList.push((topIndex, subIndex));    
    alert(indexList);
})

UPDATE

Just to clarify, the 0,0, 0,1 refer to the index values of School1 and School2 respectively under Author1 and so forth

  • 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-03T12:30:28+00:00Added an answer on June 3, 2026 at 12:30 pm

    You don’t really need the index values of the schools in order to reconstruct the list as you have the relative positions of the schools captured in the JSON structure.

    Here’s some JQuery code that will build the JSON loosely based on Imdad’s schema:

    var authors = [];
    $('#author_list > li').each(function(){
      var author = {};
      author.id = $(this).attr('id').substring(7);
      author.name = $(this).find('div.author').text();
    
      author.schools = [];
      $(this).find('ol li').each(function(){
        var school = {};
        school.sid = $(this).attr('class').substring(12);
        school.name = $(this).find('div.affiliation').text();
        author.schools.push(school);
      });
    
      authors.push(author);
    });
    
    var authorsJson = JSON.stringify(authors);
    console.log(authorsJson);
    

    Formatted results look like:

    [
      {
        "id":"8",
        "name":"Author 1",
        "schools":[
          {"sid":"7","name":"School1"},
          {"sid":"8","name":"School2"}
        ]
      },
      {
        "id":"10",
        "name":"Author 3",
        "schools":[
          {"sid":"7","name":"School1"}
        ]
      },
      {
        "id":"9",
        "name":"Author 2",
        "schools":[
          {"sid":"8","name":"School2"}
        ]
      }
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the string "re\x{0301}sume\x{0301}" (which prints like this: résumé) and I want to
I posted a question: "My Projects has c++ dll in which a db is
I have got a table structure which is as follows: `CREATE TABLE "pages" (
isJsonString('{ "Id": 1, "Name": "Coke" }') should be true and isJsonString('foo') isJsonString('<div>foo</div>') should be
The "joke" question Joel asked during podcast #58 made me all nostalgic for Logo,
Are "Visual Studio Setup" projects suitable for complex setups in different versions? The application
Does "Unit Testing" fall under white box or black box testing? Or is it
print "@_\n"; 4109 4121 6823 12967 12971 14003 20186 How do I sort it
I've got a "little" problem. A week ago my database was reaching full disk
Curious what "Toast" means? Saw this and am curious... Similar Posts How to add

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.