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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:43:37+00:00 2026-06-04T11:43:37+00:00

I know this has been asked about a million times over, however all the

  • 0

I know this has been asked about a million times over, however all the scripts I’ve found either are taylored for the person asking the question or just don’t work at all! Basically I’m limited to using normal JavaScript instead of a library like JQuery as its for a uni assignment, however would like to have stored for future use as sometimes JQuery isn’t always an option.

Anyway cutting to the chase. I have an XML file called “profiles.xml” which contains a fairly simple structure:

 <?xml version="1.0" encoding="iso-8859-1"?>
 <profiles>
 <profile id="1">
     <pic>images/profiles/person1/x.jpg</pic>
     <name>Joe Bloggs</name>
     <nickname>J-Bloggs</nickname>
     <age>21</age>
     <email>j.blogs@me.com</email>
     <role>Web Site Manager</role>
     <likes>
           <like1>Food</like1>
           <like2>Drink</like2>
           <like3>Computing</like3>
           <like4>Music</like4>
     </likes>
     <dislikes>
           <dislike1>Rude People</dislike1>
           <dislike2>Rude People</dislike2>
     </dislikes>
     <favwebsite>http://www.facebook.com</favwebsite>
 </profile>
</profiles>

So basically I’m wanting to load each profile into a seperate new array each time it needs to be accessed but in addition to that would like to do it based on the “id” attribute value. Is this possible? If so how? I’ve not got any time left to be learning stuff like XPATH etc… This needs to be done using JavaScript and that alone no server side scripting is allowed.

Also as mentioned some scripts just simply don’t work as when I try to put it into functions it comes up saying that certain variables aren’t defined even when they have been set so need the script to be passing all the information from the XML file into the new Array and have it readily accessible throughout the entire HTML document.

Please someone help, I’ve spent the past 4-5 weeks trying to work this out on my own as well as many sleepless nights searching on the net for scripts that might give me a clue!

Any help is muchly appreciated! 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-04T11:43:39+00:00Added an answer on June 4, 2026 at 11:43 am

    Unless I don’t fully understand your issue the JSFiddle/code below should help. I used a 2-d array.

    var profiles = xml.getElementsByTagName("profile");
    var arr = [];
    for (var key in profiles){
        arr.push([]);
        var nodes = profiles[key].childNodes;
        for (var ele in nodes){  
            if(nodes[ele]){
              arr[key].push(nodes[ele]);
            }
        }
    }
    console.log(arr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has been asked all over the web in various different scenarios,
I know this has been asked before but all the answers I found didn't
I know this question has been asked a million times in various ways by
I know this has kinda been asked a million times but I wanted to
I know this question has been asked many times over, but I am currently
I know this has been asked a million times before but i still can't
I know this question has been asked several times, however, after digging through question
Pardon me if this has already been asked (I know very little about Data
I know this has been asked at least a thousand times but I can't
I know this has been asked different ways several times, but I'm just not

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.