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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:38:53+00:00 2026-05-31T01:38:53+00:00

I have an xml file in which i want to read the child nodes

  • 0

I have an xml file in which i want to read the child nodes of a specific node… Below is the XML file.

The XML file structure:

<?xml version="1.0" encoding="ISO-8859-1"?>

<categories>
<category type='Type A'>
    <genre>1</genre>
    <genre>2</genre>
</category>
<category type='Type B'>
     <genre>3</genre>
     <genre>4</genre>
     <genre>5</genre>
</category>
<category type='Type C'>
    <genre>6</genre>
</category>
</categories>

An example of what i wouild need using this XML is all the genres for category type B. How exactly could i filter out all the other categories so i could do a .find(“genre”).each…. and return only genres 3,4 and 5.

Heres the code im using:

$.ajax({
        type: "GET",
        url: "myxml.xml",
        dataType: "xml",
        success: function(data){
            xml = data;
            });
        }
    });

    return {getXml : function() 
    { 
        if (xml) return xml;
    }};
})();

/* On Category Change */
$(".category").change(function(){
    var xml = xmlArtists.getXml();

    $(".genre").find("option").remove().end();

    var type = $(this).val();
    var typeGenres = $(xml).find("categories").filter(function(){
        return $(this).find("category").attr("type") == type;
    });

    typeGenres.find("genre").each(function(){
        var genre = $(this).text();
        $(".genre").append("<option value=" + genre + ">" + genre + "</option>");
    });
});

The .category is an object when its changed the code should fire… since im poulating another object upon its change but anyways thats not much of importance for this question…

Thanks in advance!!

  • 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-31T01:38:54+00:00Added an answer on May 31, 2026 at 1:38 am
    $(xml).find('category[type="Type B"] > genre')
    

    This would find all category nodes whose type is "Type B" and get all the genre child nodes of each matched category.

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

Sidebar

Related Questions

I have the following XML file with page nodes which I want to read
I have an XML file which I want to parse(below). I used an example
I have got below xml format file called ResourceData.xml . <?xml version=1.0 encoding=utf-8 ?>
need help to read xml file. i have one xml file which i want
I want to read xml file which looks like the following ... I have
I have a XML-file, which contains the data of a calendar. I want to
I have an XML file which has many section like the one below: <Operations>
I have an XML file which I'd like to query (read/write) in the same
<?xml version=1.0?> <configuration xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0> <configSections> I have a web.config file which contains xmlns in
I have one xml file which i want to store it in a internal

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.