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

  • Home
  • SEARCH
  • 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 6368329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:39:40+00:00 2026-05-25T00:39:40+00:00

I have a dynamically created xml file that contains a record with five descriptor

  • 0

I have a dynamically created xml file that contains a record with five descriptor fields. One of these is a node called “category”. I haven’t been able to find a straight answer on this anywhere. So if I had an xml file that had

<test>
   <name>Ferarri</name>
   <category>Cars</category>
</test>
<test>
   <name>Maserati</name>
   <category>Cars</category>
</test>
<test>
   <name>John Deere</name>
   <category>Trucks</category>
</test>
<test>
   <name>Ford F350</name>
   <category>Trucks</category>
</test>

Is there a way to present to the user the category field name as a list divider and then those records that contain that category node be listed below? Like below. Of course CSS styling does not apply here.

Cars
-Ferrari
-Maserati
Trucks
-John Deere
-Ford F350

Thanks for any help/tips!

From Neil’s answer (WORKS!):

 $(document).ready(function(){

                            $.ajax({
                                   type: "GET",
                                   url: "testlist.xml",
                                   dataType: "xml",
                                   success: function(xml) {
                                   var $body = $("#test-content");
                                   var $ul = $("#testList"); 
                                   var categories = new Object();
                                   var category;
                                   $(xml).find('test').each(function(){
                                                            category = $('category', this).text();
                                                            if (categories[category] == undefined){
                                                            categories[category] = $('name"', this).text();
                                                            } else {
                                                            categories[category] += ',' + $('name', this).text();
                                                            }
                                                            });
                                   for (category in categories) {
                                   $body.append('<h1>' + category + '</h1>');
                                   var vehicles = categories[category].split(',');
                                   $ul = $body.append('<ul></ul>');
                                   for (var i=0; i<vehicles.length; i++){
                                   $ul.append('<li><div data-role="collapsible" data-collapsed="true" data-theme="b"></h3>' + vehicles[i] + '</div></li>');
                                   }
                                   }
                                   }
                                   });
                            });

HTML where trying to load content:

<div data-role="page" id="testcatalog">
            <div data-role="content" id="test-content">
                <!--CONTENT SHOULD LOAD HERE-->  
            </div>
  • 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-05-25T00:39:41+00:00Added an answer on May 25, 2026 at 12:39 am

    Deon,

    I would use an “associative array” which uses the “categories” as keys and appends the “name” for each category. One the assosiative array is populated then you can iterate over the keys (categories) and extract the names. e.g.

    $.ajax({
        type: "GET",
          url: "vehicles.xml",
        dataType: "xml",
        success: function(xml) {
            var $body = $('body');
            var $ul; 
            var categories = new Object();
            var category;
                $(xml).find('test').each(function(){
                category = $('category', this).text();
                if (categories[category] == undefined){
                    categories[category] = $('name', this).text();
                } else {
                    categories[category] += ',' + $('name', this).text();
                }
            });
            for (category in categories) {
                $body.append('<h1>' + category + '</h1>');
                var vehicles = categories[category].split(',');
                $ul = $body.append('<ul></ul>');
                for (var i=0; i<vehicles.length; i++){
                    $ul.append('<li>' + vehicles[i] + '</li>');
                }
            }
        }
    });
    

    I hope this answers your question.

    Regards
    Neil

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

Sidebar

Related Questions

I have an XML file (dynamically created) and an XSL style sheet; if I
I have a dynamically created image that I am saving to a stream so
i have a table which contains a bunch of dynamically created radio button lists,
I have a page containing a control called PhoneInfo.ascx. PhoneInfo is dynamically created using
I have dynamically created a xml string form a JSON object returned from server.
I have a XML created dynamically. However, I want to add a reference to
I have to create an XML file dynamically based on the user input. Here
I have a PHP script that loads XML content dynamically: require_once 'directory/directory/'; $nice= '1149632';
I have XML file of object.I want to get instance of that object.But i
I have some dynamically created inputs which are not server-side controls. I want to

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.